Initial commit
[hashcat.git] / src / shared.c
index 45a53e5..3feb053 100644 (file)
@@ -1,45 +1,61 @@
 /**
- * Author......: Jens Steube <jens.steube@gmail.com>
+ * Authors.....: Jens Steube <jens.steube@gmail.com>
+ *               Gabriele Gristina <matrix@hashcat.net>
+ *
  * License.....: MIT
  */
 
+#ifdef OSX
+#include <stdio.h>
+#endif
+
 #include <shared.h>
 #include <limits.h>
 
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-
-/**
- * tuning tools
- */
-
-#define GET_ACCEL(x) KERNEL_ACCEL_ ## x
-#define GET_LOOPS(x) KERNEL_LOOPS_ ## x
-
 /**
- * bit rotate
+ * basic bit handling
  */
 
-uint32_t rotl32 (const uint32_t a, const uint n)
+u32 rotl32 (const u32 a, const u32 n)
 {
   return ((a << n) | (a >> (32 - n)));
 }
 
-uint32_t rotr32 (const uint32_t a, const uint n)
+u32 rotr32 (const u32 a, const u32 n)
 {
   return ((a >> n) | (a << (32 - n)));
 }
 
-uint64_t rotl64 (const uint64_t a, const uint n)
+u64 rotl64 (const u64 a, const u64 n)
 {
   return ((a << n) | (a >> (64 - n)));
 }
 
-uint64_t rotr64 (const uint64_t a, const uint n)
+u64 rotr64 (const u64 a, const u64 n)
 {
   return ((a >> n) | (a << (64 - n)));
 }
 
+u32 byte_swap_32 (const u32 n)
+{
+  return (n & 0xff000000) >> 24
+       | (n & 0x00ff0000) >>  8
+       | (n & 0x0000ff00) <<  8
+       | (n & 0x000000ff) << 24;
+}
+
+u64 byte_swap_64 (const u64 n)
+{
+  return (n & 0xff00000000000000ULL) >> 56
+       | (n & 0x00ff000000000000ULL) >> 40
+       | (n & 0x0000ff0000000000ULL) >> 24
+       | (n & 0x000000ff00000000ULL) >>  8
+       | (n & 0x00000000ff000000ULL) <<  8
+       | (n & 0x0000000000ff0000ULL) << 24
+       | (n & 0x000000000000ff00ULL) << 40
+       | (n & 0x00000000000000ffULL) << 56;
+}
+
 /**
  * ciphers for use on cpu
  */
@@ -74,7 +90,7 @@ void log_final (FILE *fp, const char *fmt, va_list ap)
     fputc ('\r', fp);
   }
 
-  char s[4096];
+  char s[4096] = { 0 };
 
   int max_len = (int) sizeof (s);
 
@@ -187,38 +203,18 @@ void log_error (const char *fmt, ...)
  * converter
  */
 
-uint byte_swap_32 (const uint n)
-{
-  return (n & 0xff000000) >> 24
-       | (n & 0x00ff0000) >>  8
-       | (n & 0x0000ff00) <<  8
-       | (n & 0x000000ff) << 24;
-}
-
-uint64_t byte_swap_64 (const uint64_t n)
-{
-  return (n & 0xff00000000000000ULL) >> 56
-       | (n & 0x00ff000000000000ULL) >> 40
-       | (n & 0x0000ff0000000000ULL) >> 24
-       | (n & 0x000000ff00000000ULL) >>  8
-       | (n & 0x00000000ff000000ULL) <<  8
-       | (n & 0x0000000000ff0000ULL) << 24
-       | (n & 0x000000000000ff00ULL) << 40
-       | (n & 0x00000000000000ffULL) << 56;
-}
-
-char int_to_base32 (const char c)
+u8 int_to_base32 (const u8 c)
 {
-  static const char tbl[0x20] =
+  static const u8 tbl[0x20] =
   {
     0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
     0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
   };
 
-  return tbl[(const uint8_t) c];
+  return tbl[c];
 }
 
-char base32_to_int (const char c)
+u8 base32_to_int (const u8 c)
 {
        if ((c >= 'A') && (c <= 'Z')) return c - 'A';
   else if ((c >= '2') && (c <= '7')) return c - '2' + 26;
@@ -226,18 +222,18 @@ char base32_to_int (const char c)
   return 0;
 }
 
-char int_to_itoa32 (const char c)
+u8 int_to_itoa32 (const u8 c)
 {
-  static const char tbl[0x20] =
+  static const u8 tbl[0x20] =
   {
     0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
     0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
   };
 
-  return tbl[(const uint8_t) c];
+  return tbl[c];
 }
 
-char itoa32_to_int (const char c)
+u8 itoa32_to_int (const u8 c)
 {
        if ((c >= '0') && (c <= '9')) return c - '0';
   else if ((c >= 'a') && (c <= 'v')) return c - 'a' + 10;
@@ -245,9 +241,9 @@ char itoa32_to_int (const char c)
   return 0;
 }
 
-char int_to_itoa64 (const char c)
+u8 int_to_itoa64 (const u8 c)
 {
-  static const char tbl[0x40] =
+  static const u8 tbl[0x40] =
   {
     0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44,
     0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54,
@@ -255,12 +251,12 @@ char int_to_itoa64 (const char c)
     0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
   };
 
-  return tbl[(const uint8_t) c];
+  return tbl[c];
 }
 
-char itoa64_to_int (const char c)
+u8 itoa64_to_int (const u8 c)
 {
-  static const char tbl[0x100] =
+  static const u8 tbl[0x100] =
   {
     0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21,
     0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31,
@@ -280,12 +276,12 @@ char itoa64_to_int (const char c)
     0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x00, 0x01, 0x02, 0x03, 0x04,
   };
 
-  return tbl[(const uint8_t) c];
+  return tbl[c];
 }
 
-char int_to_base64 (const char c)
+u8 int_to_base64 (const u8 c)
 {
-  static const char tbl[0x40] =
+  static const u8 tbl[0x40] =
   {
     0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
     0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
@@ -293,12 +289,12 @@ char int_to_base64 (const char c)
     0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f,
   };
 
-  return tbl[(const uint8_t) c];
+  return tbl[c];
 }
 
-char base64_to_int (const char c)
+u8 base64_to_int (const u8 c)
 {
-  static const char tbl[0x100] =
+  static const u8 tbl[0x100] =
   {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -318,12 +314,12 @@ char base64_to_int (const char c)
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   };
 
-  return tbl[(const uint8_t) c];
+  return tbl[c];
 }
 
-char int_to_bf64 (const char c)
+u8 int_to_bf64 (const u8 c)
 {
-  static const char tbl[0x40] =
+  static const u8 tbl[0x40] =
   {
     0x2e, 0x2f, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
     0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
@@ -331,12 +327,12 @@ char int_to_bf64 (const char c)
     0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
   };
 
-  return tbl[(const uint8_t) c];
+  return tbl[c];
 }
 
-char bf64_to_int (const char c)
+u8 bf64_to_int (const u8 c)
 {
-  static const char tbl[0x100] =
+  static const u8 tbl[0x100] =
   {
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -356,10 +352,10 @@ char bf64_to_int (const char c)
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   };
 
-  return tbl[(const uint8_t) c];
+  return tbl[c];
 }
 
-char int_to_lotus64 (const char c)
+u8 int_to_lotus64 (const u8 c)
 {
        if (c  < 10) return '0' + c;
   else if (c  < 36) return 'A' + c - 10;
@@ -370,7 +366,7 @@ char int_to_lotus64 (const char c)
   return 0;
 }
 
-char lotus64_to_int (const char c)
+u8 lotus64_to_int (const u8 c)
 {
        if ((c >= '0') && (c <= '9')) return c - '0';
   else if ((c >= 'A') && (c <= 'Z')) return c - 'A' + 10;
@@ -382,22 +378,22 @@ char lotus64_to_int (const char c)
   return 0;
 }
 
-int base32_decode (char (*f) (const char), char *in_buf, int in_len, char *out_buf)
+int base32_decode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf)
 {
-  char *in_ptr = in_buf;
+  const u8 *in_ptr = in_buf;
 
-  char *out_ptr = out_buf;
+  u8 *out_ptr = out_buf;
 
   for (int i = 0; i < in_len; i += 8)
   {
-    char out_val0 = f (in_ptr[0] & 0x7f);
-    char out_val1 = f (in_ptr[1] & 0x7f);
-    char out_val2 = f (in_ptr[2] & 0x7f);
-    char out_val3 = f (in_ptr[3] & 0x7f);
-    char out_val4 = f (in_ptr[4] & 0x7f);
-    char out_val5 = f (in_ptr[5] & 0x7f);
-    char out_val6 = f (in_ptr[6] & 0x7f);
-    char out_val7 = f (in_ptr[7] & 0x7f);
+    const u8 out_val0 = f (in_ptr[0] & 0x7f);
+    const u8 out_val1 = f (in_ptr[1] & 0x7f);
+    const u8 out_val2 = f (in_ptr[2] & 0x7f);
+    const u8 out_val3 = f (in_ptr[3] & 0x7f);
+    const u8 out_val4 = f (in_ptr[4] & 0x7f);
+    const u8 out_val5 = f (in_ptr[5] & 0x7f);
+    const u8 out_val6 = f (in_ptr[6] & 0x7f);
+    const u8 out_val7 = f (in_ptr[7] & 0x7f);
 
     out_ptr[0] =                            ((out_val0 << 3) & 0xf8) | ((out_val1 >> 2) & 0x07);
     out_ptr[1] = ((out_val1 << 6) & 0xc0) | ((out_val2 << 1) & 0x3e) | ((out_val3 >> 4) & 0x01);
@@ -421,22 +417,22 @@ int base32_decode (char (*f) (const char), char *in_buf, int in_len, char *out_b
   return out_len;
 }
 
-int base32_encode (char (*f) (const char), char *in_buf, int in_len, char *out_buf)
+int base32_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf)
 {
-  char *in_ptr = in_buf;
+  const u8 *in_ptr = in_buf;
 
-  char *out_ptr = out_buf;
+  u8 *out_ptr = out_buf;
 
   for (int i = 0; i < in_len; i += 5)
   {
-    char out_val0 = f (                            ((in_ptr[0] >> 3) & 0x1f));
-    char out_val1 = f (((in_ptr[0] << 2) & 0x1c) | ((in_ptr[1] >> 6) & 0x03));
-    char out_val2 = f (                            ((in_ptr[1] >> 1) & 0x1f));
-    char out_val3 = f (((in_ptr[1] << 4) & 0x10) | ((in_ptr[2] >> 4) & 0x0f));
-    char out_val4 = f (((in_ptr[2] << 1) & 0x1e) | ((in_ptr[3] >> 7) & 0x01));
-    char out_val5 = f (                            ((in_ptr[3] >> 2) & 0x1f));
-    char out_val6 = f (((in_ptr[3] << 3) & 0x18) | ((in_ptr[4] >> 5) & 0x07));
-    char out_val7 = f (                            ((in_ptr[4] >> 0) & 0x1f));
+    const u8 out_val0 = f (                            ((in_ptr[0] >> 3) & 0x1f));
+    const u8 out_val1 = f (((in_ptr[0] << 2) & 0x1c) | ((in_ptr[1] >> 6) & 0x03));
+    const u8 out_val2 = f (                            ((in_ptr[1] >> 1) & 0x1f));
+    const u8 out_val3 = f (((in_ptr[1] << 4) & 0x10) | ((in_ptr[2] >> 4) & 0x0f));
+    const u8 out_val4 = f (((in_ptr[2] << 1) & 0x1e) | ((in_ptr[3] >> 7) & 0x01));
+    const u8 out_val5 = f (                            ((in_ptr[3] >> 2) & 0x1f));
+    const u8 out_val6 = f (((in_ptr[3] << 3) & 0x18) | ((in_ptr[4] >> 5) & 0x07));
+    const u8 out_val7 = f (                            ((in_ptr[4] >> 0) & 0x1f));
 
     out_ptr[0] = out_val0 & 0x7f;
     out_ptr[1] = out_val1 & 0x7f;
@@ -451,30 +447,30 @@ int base32_encode (char (*f) (const char), char *in_buf, int in_len, char *out_b
     out_ptr += 8;
   }
 
-  int out_len = (in_len * 8) / 5;
+  int out_len = (int) (((0.5 + (float) in_len) * 8) / 5); // ceil (in_len * 8 / 5)
 
-  for (int i = 0; i < (7 - (in_len % 7)); i++)
+  while (out_len % 8)
   {
-    out_len++;
-
     out_buf[out_len] = '=';
+
+    out_len++;
   }
 
   return out_len;
 }
 
-int base64_decode (char (*f) (const char), char *in_buf, int in_len, char *out_buf)
+int base64_decode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf)
 {
-  char *in_ptr = in_buf;
+  const u8 *in_ptr = in_buf;
 
-  char *out_ptr = out_buf;
+  u8 *out_ptr = out_buf;
 
   for (int i = 0; i < in_len; i += 4)
   {
-    char out_val0 = f (in_ptr[0] & 0x7f);
-    char out_val1 = f (in_ptr[1] & 0x7f);
-    char out_val2 = f (in_ptr[2] & 0x7f);
-    char out_val3 = f (in_ptr[3] & 0x7f);
+    const u8 out_val0 = f (in_ptr[0] & 0x7f);
+    const u8 out_val1 = f (in_ptr[1] & 0x7f);
+    const u8 out_val2 = f (in_ptr[2] & 0x7f);
+    const u8 out_val3 = f (in_ptr[3] & 0x7f);
 
     out_ptr[0] = ((out_val0 << 2) & 0xfc) | ((out_val1 >> 4) & 0x03);
     out_ptr[1] = ((out_val1 << 4) & 0xf0) | ((out_val2 >> 2) & 0x0f);
@@ -496,18 +492,18 @@ int base64_decode (char (*f) (const char), char *in_buf, int in_len, char *out_b
   return out_len;
 }
 
-int base64_encode (char (*f) (const char), char *in_buf, int in_len, char *out_buf)
+int base64_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf)
 {
-  char *in_ptr = in_buf;
+  const u8 *in_ptr = in_buf;
 
-  char *out_ptr = out_buf;
+  u8 *out_ptr = out_buf;
 
   for (int i = 0; i < in_len; i += 3)
   {
-    char out_val0 = f (                            ((in_ptr[0] >> 2) & 0x3f));
-    char out_val1 = f (((in_ptr[0] << 4) & 0x30) | ((in_ptr[1] >> 4) & 0x0f));
-    char out_val2 = f (((in_ptr[1] << 2) & 0x3c) | ((in_ptr[2] >> 6) & 0x03));
-    char out_val3 = f (                            ((in_ptr[2] >> 0) & 0x3f));
+    const u8 out_val0 = f (                            ((in_ptr[0] >> 2) & 0x3f));
+    const u8 out_val1 = f (((in_ptr[0] << 4) & 0x30) | ((in_ptr[1] >> 4) & 0x0f));
+    const u8 out_val2 = f (((in_ptr[1] << 2) & 0x3c) | ((in_ptr[2] >> 6) & 0x03));
+    const u8 out_val3 = f (                            ((in_ptr[2] >> 0) & 0x3f));
 
     out_ptr[0] = out_val0 & 0x7f;
     out_ptr[1] = out_val1 & 0x7f;
@@ -518,25 +514,116 @@ int base64_encode (char (*f) (const char), char *in_buf, int in_len, char *out_b
     out_ptr += 4;
   }
 
-  int out_len = (in_len * 8) / 6;
+  int out_len = (int) (((0.5 + (float) in_len) * 8) / 6); // ceil (in_len * 8 / 6)
 
-  for (int i = 0; i < (3 - (in_len % 3)); i++)
+  while (out_len % 4)
   {
-    out_len++;
-
     out_buf[out_len] = '=';
+
+    out_len++;
   }
 
   return out_len;
 }
 
-static void AES128_decrypt_cbc (const uint key[4], const uint iv[4], const uint in[16], uint out[16])
+int is_valid_hex_char (const u8 c)
+{
+  if ((c >= '0') && (c <= '9')) return 1;
+  if ((c >= 'A') && (c <= 'F')) return 1;
+  if ((c >= 'a') && (c <= 'f')) return 1;
+
+  return 0;
+}
+
+u8 hex_convert (const u8 c)
+{
+  return (c & 15) + (c >> 6) * 9;
+}
+
+u8 hex_to_u8 (const u8 hex[2])
+{
+  u8 v = 0;
+
+  v |= (hex_convert (hex[1]) <<  0);
+  v |= (hex_convert (hex[0]) <<  4);
+
+  return (v);
+}
+
+u32 hex_to_u32 (const u8 hex[8])
+{
+  u32 v = 0;
+
+  v |= ((u32) hex_convert (hex[7])) <<  0;
+  v |= ((u32) hex_convert (hex[6])) <<  4;
+  v |= ((u32) hex_convert (hex[5])) <<  8;
+  v |= ((u32) hex_convert (hex[4])) << 12;
+  v |= ((u32) hex_convert (hex[3])) << 16;
+  v |= ((u32) hex_convert (hex[2])) << 20;
+  v |= ((u32) hex_convert (hex[1])) << 24;
+  v |= ((u32) hex_convert (hex[0])) << 28;
+
+  return (v);
+}
+
+u64 hex_to_u64 (const u8 hex[16])
+{
+  u64 v = 0;
+
+  v |= ((u64) hex_convert (hex[15]) <<  0);
+  v |= ((u64) hex_convert (hex[14]) <<  4);
+  v |= ((u64) hex_convert (hex[13]) <<  8);
+  v |= ((u64) hex_convert (hex[12]) << 12);
+  v |= ((u64) hex_convert (hex[11]) << 16);
+  v |= ((u64) hex_convert (hex[10]) << 20);
+  v |= ((u64) hex_convert (hex[ 9]) << 24);
+  v |= ((u64) hex_convert (hex[ 8]) << 28);
+  v |= ((u64) hex_convert (hex[ 7]) << 32);
+  v |= ((u64) hex_convert (hex[ 6]) << 36);
+  v |= ((u64) hex_convert (hex[ 5]) << 40);
+  v |= ((u64) hex_convert (hex[ 4]) << 44);
+  v |= ((u64) hex_convert (hex[ 3]) << 48);
+  v |= ((u64) hex_convert (hex[ 2]) << 52);
+  v |= ((u64) hex_convert (hex[ 1]) << 56);
+  v |= ((u64) hex_convert (hex[ 0]) << 60);
+
+  return (v);
+}
+
+void bin_to_hex_lower (const u32 v, u8 hex[8])
+{
+  hex[0] = v >> 28 & 15;
+  hex[1] = v >> 24 & 15;
+  hex[2] = v >> 20 & 15;
+  hex[3] = v >> 16 & 15;
+  hex[4] = v >> 12 & 15;
+  hex[5] = v >>  8 & 15;
+  hex[6] = v >>  4 & 15;
+  hex[7] = v >>  0 & 15;
+
+  u32 add;
+
+  hex[0] += 6; add = ((hex[0] & 0x10) >> 4) * 39; hex[0] += 42 + add;
+  hex[1] += 6; add = ((hex[1] & 0x10) >> 4) * 39; hex[1] += 42 + add;
+  hex[2] += 6; add = ((hex[2] & 0x10) >> 4) * 39; hex[2] += 42 + add;
+  hex[3] += 6; add = ((hex[3] & 0x10) >> 4) * 39; hex[3] += 42 + add;
+  hex[4] += 6; add = ((hex[4] & 0x10) >> 4) * 39; hex[4] += 42 + add;
+  hex[5] += 6; add = ((hex[5] & 0x10) >> 4) * 39; hex[5] += 42 + add;
+  hex[6] += 6; add = ((hex[6] & 0x10) >> 4) * 39; hex[6] += 42 + add;
+  hex[7] += 6; add = ((hex[7] & 0x10) >> 4) * 39; hex[7] += 42 + add;
+}
+
+/**
+ * decoder
+ */
+
+static void AES128_decrypt_cbc (const u32 key[4], const u32 iv[4], const u32 in[16], u32 out[16])
 {
   AES_KEY skey;
 
-  AES_set_decrypt_key ((unsigned char *) key, 128, &skey);
+  AES_set_decrypt_key ((const u8 *) key, 128, &skey);
 
-  uint _iv[4];
+  u32 _iv[4] = { 0 };
 
   _iv[0] = iv[0];
   _iv[1] = iv[1];
@@ -545,15 +632,15 @@ static void AES128_decrypt_cbc (const uint key[4], const uint iv[4], const uint
 
   for (int i = 0; i < 16; i += 4)
   {
-    uint _in[4];
-    uint _out[4];
+    u32 _in[4] = { 0 };
+    u32 _out[4] = { 0 };
 
     _in[0] = in[i + 0];
     _in[1] = in[i + 1];
     _in[2] = in[i + 2];
     _in[3] = in[i + 3];
 
-    AES_decrypt (&skey, (char *) _in, (char *) _out);
+    AES_decrypt (&skey, (const u8 *) _in, (u8 *) _out);
 
     _out[0] ^= _iv[0];
     _out[1] ^= _iv[1];
@@ -576,15 +663,13 @@ static void juniper_decrypt_hash (char *in, char *out)
 {
   // base64 decode
 
-  char base64_buf[100];
+  u8 base64_buf[100] = { 0 };
 
-  memset (base64_buf, 0, sizeof (base64_buf));
-
-  base64_decode (base64_to_int, in, DISPLAY_LEN_MIN_501, base64_buf);
+  base64_decode (base64_to_int, (const u8 *) in, DISPLAY_LEN_MIN_501, base64_buf);
 
   // iv stuff
 
-  uint juniper_iv[4] = { 0 };
+  u32 juniper_iv[4] = { 0 };
 
   memcpy (juniper_iv, base64_buf, 12);
 
@@ -592,7 +677,7 @@ static void juniper_decrypt_hash (char *in, char *out)
 
   // reversed key
 
-  uint juniper_key[4];
+  u32 juniper_key[4] = { 0 };
 
   juniper_key[0] = byte_swap_32 (0xa6707a7e);
   juniper_key[1] = byte_swap_32 (0x8df91059);
@@ -601,100 +686,13 @@ static void juniper_decrypt_hash (char *in, char *out)
 
   // AES decrypt
 
-  uint *in_ptr  = (uint *) (base64_buf + 12);
-  uint *out_ptr = (uint *) (out        + 12);
+  u32 *in_ptr  = (u32 *) (base64_buf + 12);
+  u32 *out_ptr = (u32 *) (out        + 12);
 
   AES128_decrypt_cbc (juniper_key, juniper_iv, in_ptr, out_ptr);
 }
 
-uint is_valid_hex_char (const char c)
-{
-  if ((c >= '0') && (c <= '9')) return 1;
-  if ((c >= 'A') && (c <= 'F')) return 1;
-  if ((c >= 'a') && (c <= 'f')) return 1;
-
-  return 0;
-}
-
-char hex_convert (const char c)
-{
-  return (c & 15) + (c >> 6) * 9;
-}
-
-char hex_to_char (const char hex[2])
-{
-  char v = 0;
-
-  v |= (hex_convert (hex[1]) <<  0);
-  v |= (hex_convert (hex[0]) <<  4);
-
-  return (v);
-}
-
-uint hex_to_uint (const char hex[8])
-{
-  uint v = 0;
-
-  v |= hex_convert (hex[7]) <<  0;
-  v |= hex_convert (hex[6]) <<  4;
-  v |= hex_convert (hex[5]) <<  8;
-  v |= hex_convert (hex[4]) << 12;
-  v |= hex_convert (hex[3]) << 16;
-  v |= hex_convert (hex[2]) << 20;
-  v |= hex_convert (hex[1]) << 24;
-  v |= hex_convert (hex[0]) << 28;
-
-  return (v);
-}
-
-uint64_t hex_to_uint64_t (const char hex[16])
-{
-  uint64_t v = 0;
-
-  v |= ((uint64_t) hex_convert (hex[15]) <<  0);
-  v |= ((uint64_t) hex_convert (hex[14]) <<  4);
-  v |= ((uint64_t) hex_convert (hex[13]) <<  8);
-  v |= ((uint64_t) hex_convert (hex[12]) << 12);
-  v |= ((uint64_t) hex_convert (hex[11]) << 16);
-  v |= ((uint64_t) hex_convert (hex[10]) << 20);
-  v |= ((uint64_t) hex_convert (hex[ 9]) << 24);
-  v |= ((uint64_t) hex_convert (hex[ 8]) << 28);
-  v |= ((uint64_t) hex_convert (hex[ 7]) << 32);
-  v |= ((uint64_t) hex_convert (hex[ 6]) << 36);
-  v |= ((uint64_t) hex_convert (hex[ 5]) << 40);
-  v |= ((uint64_t) hex_convert (hex[ 4]) << 44);
-  v |= ((uint64_t) hex_convert (hex[ 3]) << 48);
-  v |= ((uint64_t) hex_convert (hex[ 2]) << 52);
-  v |= ((uint64_t) hex_convert (hex[ 1]) << 56);
-  v |= ((uint64_t) hex_convert (hex[ 0]) << 60);
-
-  return (v);
-}
-
-void bin_to_hex_lower (uint v, char hex[8])
-{
-  hex[0] = v >> 28 & 15;
-  hex[1] = v >> 24 & 15;
-  hex[2] = v >> 20 & 15;
-  hex[3] = v >> 16 & 15;
-  hex[4] = v >> 12 & 15;
-  hex[5] = v >>  8 & 15;
-  hex[6] = v >>  4 & 15;
-  hex[7] = v >>  0 & 15;
-
-  uint add;
-
-  hex[0] += 6; add = ((hex[0] & 0x10) >> 4) * 39; hex[0] += 42 + add;
-  hex[1] += 6; add = ((hex[1] & 0x10) >> 4) * 39; hex[1] += 42 + add;
-  hex[2] += 6; add = ((hex[2] & 0x10) >> 4) * 39; hex[2] += 42 + add;
-  hex[3] += 6; add = ((hex[3] & 0x10) >> 4) * 39; hex[3] += 42 + add;
-  hex[4] += 6; add = ((hex[4] & 0x10) >> 4) * 39; hex[4] += 42 + add;
-  hex[5] += 6; add = ((hex[5] & 0x10) >> 4) * 39; hex[5] += 42 + add;
-  hex[6] += 6; add = ((hex[6] & 0x10) >> 4) * 39; hex[6] += 42 + add;
-  hex[7] += 6; add = ((hex[7] & 0x10) >> 4) * 39; hex[7] += 42 + add;
-}
-
-void phpass_decode (unsigned char digest[16], unsigned char buf[22])
+void phpass_decode (u8 digest[16], u8 buf[22])
 {
   int l;
 
@@ -749,7 +747,7 @@ void phpass_decode (unsigned char digest[16], unsigned char buf[22])
   digest[15] = (l >>  0) & 0xff;
 }
 
-void phpass_encode (unsigned char digest[16], unsigned char buf[22])
+void phpass_encode (u8 digest[16], u8 buf[22])
 {
   int l;
 
@@ -794,7 +792,7 @@ void phpass_encode (unsigned char digest[16], unsigned char buf[22])
   buf[21] = int_to_itoa64 (l & 0x3f);
 }
 
-void md5crypt_decode (unsigned char digest[16], unsigned char buf[22])
+void md5crypt_decode (u8 digest[16], u8 buf[22])
 {
   int l;
 
@@ -849,7 +847,7 @@ void md5crypt_decode (unsigned char digest[16], unsigned char buf[22])
   digest[11] = (l >>  0) & 0xff;
 }
 
-void md5crypt_encode (unsigned char digest[16], unsigned char buf[22])
+void md5crypt_encode (u8 digest[16], u8 buf[22])
 {
   int l;
 
@@ -894,7 +892,7 @@ void md5crypt_encode (unsigned char digest[16], unsigned char buf[22])
   buf[21] = int_to_itoa64 (l & 0x3f); l >>= 6;
 }
 
-void sha512crypt_decode (unsigned char digest[64], unsigned char buf[86])
+void sha512crypt_decode (u8 digest[64], u8 buf[86])
 {
   int l;
 
@@ -1093,7 +1091,7 @@ void sha512crypt_decode (unsigned char digest[64], unsigned char buf[86])
   digest[63] = (l >>  0) & 0xff;
 }
 
-void sha512crypt_encode (unsigned char digest[64], unsigned char buf[86])
+void sha512crypt_encode (u8 digest[64], u8 buf[86])
 {
   int l;
 
@@ -1250,7 +1248,7 @@ void sha512crypt_encode (unsigned char digest[64], unsigned char buf[86])
   buf[85] = int_to_itoa64 (l & 0x3f); l >>= 6;
 }
 
-void sha1aix_decode (unsigned char digest[20], unsigned char buf[27])
+void sha1aix_decode (u8 digest[20], u8 buf[27])
 {
   int l;
 
@@ -1316,7 +1314,7 @@ void sha1aix_decode (unsigned char digest[20], unsigned char buf[27])
   digest[18] = (l >> 16) & 0xff;
 }
 
-void sha1aix_encode (unsigned char digest[20], unsigned char buf[27])
+void sha1aix_encode (u8 digest[20], u8 buf[27])
 {
   int l;
 
@@ -1369,7 +1367,7 @@ void sha1aix_encode (unsigned char digest[20], unsigned char buf[27])
   buf[26] = int_to_itoa64 (l & 0x3f);
 }
 
-void sha256aix_decode (unsigned char digest[32], unsigned char buf[43])
+void sha256aix_decode (u8 digest[32], u8 buf[43])
 {
   int l;
 
@@ -1472,7 +1470,7 @@ void sha256aix_decode (unsigned char digest[32], unsigned char buf[43])
   digest[30] = (l >> 16) & 0xff;
 }
 
-void sha256aix_encode (unsigned char digest[32], unsigned char buf[43])
+void sha256aix_encode (u8 digest[32], u8 buf[43])
 {
   int l;
 
@@ -1553,7 +1551,7 @@ void sha256aix_encode (unsigned char digest[32], unsigned char buf[43])
   buf[42] = int_to_itoa64 (l & 0x3f);
 }
 
-void sha512aix_decode (unsigned char digest[64], unsigned char buf[86])
+void sha512aix_decode (u8 digest[64], u8 buf[86])
 {
   int l;
 
@@ -1752,7 +1750,7 @@ void sha512aix_decode (unsigned char digest[64], unsigned char buf[86])
   digest[63] = (l >> 16) & 0xff;
 }
 
-void sha512aix_encode (unsigned char digest[64], unsigned char buf[86])
+void sha512aix_encode (u8 digest[64], u8 buf[86])
 {
   int l;
 
@@ -1909,7 +1907,7 @@ void sha512aix_encode (unsigned char digest[64], unsigned char buf[86])
   buf[85] = int_to_itoa64 (l & 0x3f); l >>= 6;
 }
 
-void sha256crypt_decode (unsigned char digest[32], unsigned char buf[43])
+void sha256crypt_decode (u8 digest[32], u8 buf[43])
 {
   int l;
 
@@ -2011,7 +2009,7 @@ void sha256crypt_decode (unsigned char digest[32], unsigned char buf[43])
   digest[30] = (l >>  0) & 0xff;
 }
 
-void sha256crypt_encode (unsigned char digest[32], unsigned char buf[43])
+void sha256crypt_encode (u8 digest[32], u8 buf[43])
 {
   int l;
 
@@ -2092,7 +2090,7 @@ void sha256crypt_encode (unsigned char digest[32], unsigned char buf[43])
   buf[42] = int_to_itoa64 (l & 0x3f);
 }
 
-void drupal7_decode (unsigned char digest[64], unsigned char buf[44])
+void drupal7_decode (u8 digest[64], u8 buf[44])
 {
   int l;
 
@@ -2228,7 +2226,7 @@ void drupal7_decode (unsigned char digest[64], unsigned char buf[44])
   digest[63] = 0;
 }
 
-void drupal7_encode (unsigned char digest[64], unsigned char buf[43])
+void drupal7_encode (u8 digest[64], u8 buf[43])
 {
   int l;
 
@@ -2445,6 +2443,8 @@ int tty_getchar()
 
   DWORD num = 0;
 
+  memset (buf, 0, sizeof (buf));
+
   ReadConsoleInput (stdinHandle, buf, 100, &num);
 
   FlushConsoleInputBuffer (stdinHandle);
@@ -2600,7 +2600,7 @@ char *logfile_generate_topid ()
 
   char *topid = (char *) mymalloc (1 + 16 + 1);
 
-  sprintf (topid, "TOP%08x", id);
+  snprintf (topid, 1 + 16, "TOP%08x", id);
 
   return topid;
 }
@@ -2611,7 +2611,7 @@ char *logfile_generate_subid ()
 
   char *subid = (char *) mymalloc (1 + 16 + 1);
 
-  sprintf (subid, "SUB%08x", id);
+  snprintf (subid, 1 + 16, "SUB%08x", id);
 
   return subid;
 }
@@ -2620,6 +2620,36 @@ char *logfile_generate_subid ()
  * system
  */
 
+#if F_SETLKW
+void lock_file (FILE *fp)
+{
+  struct flock lock;
+
+  memset (&lock, 0, sizeof (struct flock));
+
+  lock.l_type = F_WRLCK;
+  while (fcntl(fileno(fp), F_SETLKW, &lock))
+  {
+    if (errno != EINTR)
+    {
+      log_error ("ERROR: failed acquiring write lock: %s", strerror (errno));
+
+      exit (-1);
+    }
+  }
+}
+
+void unlock_file (FILE *fp)
+{
+  struct flock lock;
+
+  memset (&lock, 0, sizeof (struct flock));
+
+  lock.l_type = F_UNLCK;
+  fcntl(fileno(fp), F_SETLK, &lock);
+}
+#endif // F_SETLKW
+
 #ifdef _WIN
 void fsync (int fd)
 {
@@ -2633,12 +2663,13 @@ void fsync (int fd)
  * thermal
  */
 
-#ifdef _WIN
+#ifdef HAVE_HWMON
+#if defined(_WIN) && defined(HAVE_NVAPI)
 int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
 {
   NvU32 pGpuCount;
 
-  if (hc_NvAPI_EnumPhysicalGPUs (nvGPUHandle, &pGpuCount) != NVAPI_OK) return (0);
+  if (hm_NvAPI_EnumPhysicalGPUs (data.hm_nv, nvGPUHandle, &pGpuCount) != NVAPI_OK) return (0);
 
   if (pGpuCount == 0)
   {
@@ -2649,20 +2680,20 @@ int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
 
   return (pGpuCount);
 }
-#endif
+#endif // _WIN && HAVE_NVAPI
 
-#ifdef LINUX
+#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 (hc_NVML_nvmlDeviceGetHandleByIndex (data.hm_dll_nv, 1, i, &nvGPUHandle[i]) != NVML_SUCCESS) break;
+    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));
-    //hc_NVML_nvmlDeviceGetName (data.hm_dll_nv, nvGPUHandle[i], name, sizeof (name) - 1);
+    // 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++;
   }
@@ -2676,52 +2707,12 @@ int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
 
   return (pGpuCount);
 }
-#endif
-
-void hm_close (HM_LIB hm_dll)
-{
-  #ifdef _POSIX
-  dlclose (hm_dll);
-
-  #elif _WIN
-  FreeLibrary (hm_dll);
-
-  #endif
-}
-
-HM_LIB hm_init (const cl_uint vendor_id)
-{
-  HM_LIB hm_dll = NULL;
-
-  if (vendor_id == VENDOR_ID_AMD)
-  {
-    #ifdef _POSIX
-    hm_dll = dlopen ("libatiadlxx.so", RTLD_LAZY | RTLD_GLOBAL);
-
-    #elif _WIN
-    hm_dll = LoadLibrary ("atiadlxx.dll");
-
-    if (hm_dll == NULL)
-    {
-      hm_dll = LoadLibrary ("atiadlxy.dll");
-    }
-
-    #endif
-  }
-
-  #ifdef LINUX
-  if (vendor_id == VENDOR_ID_NV)
-  {
-    hm_dll = dlopen ("libnvidia-ml.so", RTLD_LAZY | RTLD_GLOBAL);
-  }
-  #endif
-
-  return hm_dll;
-}
+#endif // LINUX && HAVE_NVML
 
-int get_adapters_num_amd (HM_LIB hm_dll_amd, int *iNumberAdapters)
+#ifdef HAVE_ADL
+int get_adapters_num_amd (void *adl, int *iNumberAdapters)
 {
-  if (hc_ADL_Adapter_NumberOfAdapters_Get (hm_dll_amd, iNumberAdapters) != ADL_OK) return -1;
+  if (hm_ADL_Adapter_NumberOfAdapters_Get ((ADL_PTR *) adl, iNumberAdapters) != ADL_OK) return -1;
 
   if (iNumberAdapters == 0)
   {
@@ -2742,7 +2733,7 @@ int hm_show_performance_level (HM_LIB hm_dll, int iAdapterIndex)
   lpOdParameters.iSize = sizeof (ADLODParameters);
   size_t plevels_size = 0;
 
-  if (hc_ADL_Overdrive_ODParameters_Get (hm_dll, iAdapterIndex, &lpOdParameters) != ADL_OK) return -1;
+  if (hm_ADL_Overdrive_ODParameters_Get (hm_dll, iAdapterIndex, &lpOdParameters) != ADL_OK) return -1;
 
   log_info ("[DEBUG] %s, adapter %d performance level (%d) : %s %s",
           __func__, iAdapterIndex,
@@ -2756,7 +2747,7 @@ int hm_show_performance_level (HM_LIB hm_dll, int iAdapterIndex)
 
   lpOdPerformanceLevels->iSize = sizeof (ADLODPerformanceLevels) + sizeof (ADLODPerformanceLevel) * (lpOdParameters.iNumberOfPerformanceLevels - 1);
 
-  if (hc_ADL_Overdrive_ODPerformanceLevels_Get (hm_dll, iAdapterIndex, 0, lpOdPerformanceLevels) != ADL_OK) return -1;
+  if (hm_ADL_Overdrive_ODPerformanceLevels_Get (hm_dll, iAdapterIndex, 0, lpOdPerformanceLevels) != ADL_OK) return -1;
 
   for (int j = 0; j < lpOdParameters.iNumberOfPerformanceLevels; j++)
     log_info ("[DEBUG] %s, adapter %d, level %d : engine %d, memory %d, voltage: %d",
@@ -2769,13 +2760,13 @@ int hm_show_performance_level (HM_LIB hm_dll, int iAdapterIndex)
 }
 */
 
-LPAdapterInfo hm_get_adapter_info_amd (HM_LIB hm_dll_amd, int iNumberAdapters)
+LPAdapterInfo hm_get_adapter_info_amd (void *adl, int iNumberAdapters)
 {
   size_t AdapterInfoSize = iNumberAdapters * sizeof (AdapterInfo);
 
   LPAdapterInfo lpAdapterInfo = (LPAdapterInfo) mymalloc (AdapterInfoSize);
 
-  if (hc_ADL_Adapter_AdapterInfo_Get (hm_dll_amd, lpAdapterInfo, AdapterInfoSize) != ADL_OK) return NULL;
+  if (hm_ADL_Adapter_AdapterInfo_Get ((ADL_PTR *) adl, lpAdapterInfo, AdapterInfoSize) != ADL_OK) return NULL;
 
   return lpAdapterInfo;
 }
@@ -2787,7 +2778,7 @@ LPAdapterInfo hm_get_adapter_info_amd (HM_LIB hm_dll_amd, int iNumberAdapters)
 
 int hm_get_opencl_device_index (hm_attrs_t *hm_device, uint num_adl_adapters, int bus_num, int dev_num)
 {
-  uint32_t idx = -1;
+  u32 idx = -1;
 
   for (uint i = 0; i < num_adl_adapters; i++)
   {
@@ -2821,7 +2812,7 @@ void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices,
 }
 */
 
-void hm_sort_adl_adapters_by_busid_devid (uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo)
+void hm_sort_adl_adapters_by_busid_devid (u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo)
 {
   // basically bubble sort
 
@@ -2831,19 +2822,19 @@ void hm_sort_adl_adapters_by_busid_devid (uint32_t *valid_adl_device_list, int n
     {
       // get info of adapter [x]
 
-      uint32_t adapter_index_x = valid_adl_device_list[j];
+      u32 adapter_index_x = valid_adl_device_list[j];
       AdapterInfo info_x = lpAdapterInfo[adapter_index_x];
 
-      uint32_t bus_num_x = info_x.iBusNumber;
-      uint32_t dev_num_x = info_x.iDeviceNumber;
+      u32 bus_num_x = info_x.iBusNumber;
+      u32 dev_num_x = info_x.iDeviceNumber;
 
       // get info of adapter [y]
 
-      uint32_t adapter_index_y = valid_adl_device_list[j + 1];
+      u32 adapter_index_y = valid_adl_device_list[j + 1];
       AdapterInfo info_y = lpAdapterInfo[adapter_index_y];
 
-      uint32_t bus_num_y = info_y.iBusNumber;
-      uint32_t dev_num_y = info_y.iDeviceNumber;
+      u32 bus_num_y = info_y.iBusNumber;
+      u32 dev_num_y = info_y.iDeviceNumber;
 
       uint need_swap = 0;
 
@@ -2861,7 +2852,7 @@ void hm_sort_adl_adapters_by_busid_devid (uint32_t *valid_adl_device_list, int n
 
       if (need_swap == 1)
       {
-        uint32_t temp = valid_adl_device_list[j + 1];
+        u32 temp = valid_adl_device_list[j + 1];
 
         valid_adl_device_list[j + 1] = valid_adl_device_list[j];
         valid_adl_device_list[j + 0] = temp;
@@ -2870,11 +2861,11 @@ void hm_sort_adl_adapters_by_busid_devid (uint32_t *valid_adl_device_list, int n
   }
 }
 
-uint32_t *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo)
+u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo)
 {
   *num_adl_adapters = 0;
 
-  uint32_t *adl_adapters = NULL;
+  u32 *adl_adapters = NULL;
 
   int *bus_numbers    = NULL;
   int *device_numbers = NULL;
@@ -2883,7 +2874,7 @@ uint32_t *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adap
   {
     AdapterInfo info = lpAdapterInfo[i];
 
-    if ((info.strUDID == NULL) || (strlen (info.strUDID) < 1)) continue;
+    if (strlen (info.strUDID) < 1) continue;
 
     #ifdef WIN
     if (info.iVendorID !=   1002) continue;
@@ -2909,7 +2900,7 @@ uint32_t *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adap
 
     // add it to the list
 
-    adl_adapters = (uint32_t *) myrealloc (adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int));
+    adl_adapters = (u32 *) myrealloc (adl_adapters, (*num_adl_adapters) * sizeof (int), sizeof (int));
 
     adl_adapters[*num_adl_adapters] = i;
 
@@ -2934,13 +2925,13 @@ uint32_t *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adap
   return adl_adapters;
 }
 
-int hm_check_fanspeed_control (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo)
+int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo)
 {
   // loop through all valid devices
 
   for (int i = 0; i < num_adl_adapters; i++)
   {
-    uint32_t adapter_index = valid_adl_device_list[i];
+    u32 adapter_index = valid_adl_device_list[i];
 
     // get AdapterInfo
 
@@ -2952,7 +2943,7 @@ int hm_check_fanspeed_control (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_
 
     int opencl_device_index = i;
 
-    // if (hm_show_performance_level (hm_dll_amd, info.iAdapterIndex) != 0) return -1;
+    // if (hm_show_performance_level (adl, info.iAdapterIndex) != 0) return -1;
 
     // get fanspeed info
 
@@ -2964,7 +2955,7 @@ int hm_check_fanspeed_control (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_
 
       FanSpeedInfo.iSize = sizeof (ADLFanSpeedInfo);
 
-      if (hc_ADL_Overdrive5_FanSpeedInfo_Get (hm_dll_amd, info.iAdapterIndex, 0, &FanSpeedInfo) != ADL_OK) return -1;
+      if (hm_ADL_Overdrive5_FanSpeedInfo_Get (adl, info.iAdapterIndex, 0, &FanSpeedInfo) != ADL_OK) return -1;
 
       // check read and write capability in fanspeedinfo
 
@@ -2984,7 +2975,7 @@ int hm_check_fanspeed_control (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_
 
       memset (&faninfo, 0, sizeof (faninfo));
 
-      if (hc_ADL_Overdrive6_FanSpeed_Get (hm_dll_amd, info.iAdapterIndex, &faninfo) != ADL_OK) return -1;
+      if (hm_ADL_Overdrive6_FanSpeed_Get (adl, info.iAdapterIndex, &faninfo) != ADL_OK) return -1;
 
       // check read capability in fanspeedinfo
 
@@ -3002,11 +2993,11 @@ int hm_check_fanspeed_control (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_
   return 0;
 }
 
-int hm_get_overdrive_version (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo)
+int hm_get_overdrive_version (void *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++)
   {
-    uint32_t adapter_index = valid_adl_device_list[i];
+    u32 adapter_index = valid_adl_device_list[i];
 
     // get AdapterInfo
 
@@ -3018,7 +3009,7 @@ int hm_get_overdrive_version (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_t
     int od_enabled   = 0;
     int od_version   = 0;
 
-    if (hc_ADL_Overdrive_Caps (hm_dll_amd, info.iAdapterIndex, &od_supported, &od_enabled, &od_version) != ADL_OK) return -1;
+    if (hm_ADL_Overdrive_Caps (adl, info.iAdapterIndex, &od_supported, &od_enabled, &od_version) != ADL_OK) return -1;
 
     // store the overdrive version in hm_device
 
@@ -3034,11 +3025,11 @@ int hm_get_overdrive_version (HM_LIB hm_dll_amd, hm_attrs_t *hm_device, uint32_t
   return 0;
 }
 
-int hm_get_adapter_index_amd (hm_attrs_t *hm_device, uint32_t *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo)
+int hm_get_adapter_index_amd (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++)
   {
-    uint32_t adapter_index = valid_adl_device_list[i];
+    u32 adapter_index = valid_adl_device_list[i];
 
     // get AdapterInfo
 
@@ -3057,14 +3048,16 @@ int hm_get_adapter_index_amd (hm_attrs_t *hm_device, uint32_t *valid_adl_device_
 
   return num_adl_adapters;
 }
+#endif // HAVE_ADL
 
 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.hm_dll_amd)
+    if (data.hm_amd)
     {
       if (data.hm_device[device_id].od_version == 5)
       {
@@ -3072,7 +3065,7 @@ int hm_get_temperature_with_device_id (const uint device_id)
 
         Temperature.iSize = sizeof (ADLTemperature);
 
-        if (hc_ADL_Overdrive5_Temperature_Get (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, 0, &Temperature) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive5_Temperature_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &Temperature) != ADL_OK) return -1;
 
         return Temperature.iTemperature / 1000;
       }
@@ -3080,23 +3073,26 @@ int hm_get_temperature_with_device_id (const uint device_id)
       {
         int Temperature = 0;
 
-        if (hc_ADL_Overdrive6_Temperature_Get (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, &Temperature) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive6_Temperature_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &Temperature) != ADL_OK) return -1;
 
         return Temperature / 1000;
       }
     }
   }
-  else if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
+  #endif
+
+  #if defined(HAVE_NVML) || defined(HAVE_NVAPI)
+  if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
   {
-    #ifdef LINUX
+    #if defined(LINUX) && defined(HAVE_NVML)
     int temperature = 0;
 
-    hc_NVML_nvmlDeviceGetTemperature (data.hm_dll_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_GPU, (unsigned int *) &temperature);
+    hm_NVML_nvmlDeviceGetTemperature (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_GPU, (unsigned int *) &temperature);
 
     return temperature;
     #endif
 
-    #ifdef WIN
+    #if defined(WIN) && defined(HAVE_NVAPI)
     NV_GPU_THERMAL_SETTINGS pThermalSettings;
 
     pThermalSettings.version = NV_GPU_THERMAL_SETTINGS_VER;
@@ -3104,11 +3100,12 @@ int hm_get_temperature_with_device_id (const uint device_id)
     pThermalSettings.sensor[0].controller = NVAPI_THERMAL_CONTROLLER_UNKNOWN;
     pThermalSettings.sensor[0].target = NVAPI_THERMAL_TARGET_GPU;
 
-    if (hc_NvAPI_GPU_GetThermalSettings (data.hm_device[device_id].adapter_index.nv, 0, &pThermalSettings) != NVAPI_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 pThermalSettings.sensor[0].currentTemp;
-    #endif
+    #endif // WIN && HAVE_NVAPI
   }
+  #endif // HAVE_NVML || HAVE_NVAPI
 
   return -1;
 }
@@ -3120,9 +3117,10 @@ 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.hm_dll_amd)
+      if (data.hm_amd)
       {
         if (data.hm_device[device_id].od_version == 5)
         {
@@ -3134,7 +3132,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 (hc_ADL_Overdrive5_FanSpeed_Get (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
+          if (hm_ADL_Overdrive5_FanSpeed_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
 
           return lpFanSpeedValue.iFanSpeed;
         }
@@ -3144,30 +3142,37 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
 
           memset (&faninfo, 0, sizeof (faninfo));
 
-          if (hc_ADL_Overdrive6_FanSpeed_Get (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, &faninfo) != ADL_OK) return -1;
+          if (hm_ADL_Overdrive6_FanSpeed_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &faninfo) != ADL_OK) return -1;
 
           return faninfo.iFanSpeedPercent;
         }
       }
     }
-    else if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
+    #endif // HAVE_ADL
+
+    #if defined(HAVE_NVML) || defined(HAVE_NVAPI)
+    if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
     {
-      #ifdef LINUX
+      #if defined(LINUX) && defined(HAVE_NVML)
       int speed = 0;
 
-      hc_NVML_nvmlDeviceGetFanSpeed (data.hm_dll_nv, 1, data.hm_device[device_id].adapter_index.nv, (unsigned int *) &speed);
+      hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nv, 1, data.hm_device[device_id].adapter_index.nv, (unsigned int *) &speed);
 
       return speed;
       #endif
 
-      #ifdef WIN
-      NvU32 speed = 0;
+      #if defined(WIN) && defined(HAVE_NVAPI)
 
-      hc_NvAPI_GPU_GetTachReading (data.hm_device[device_id].adapter_index.nv, &speed);
+      NV_GPU_COOLER_SETTINGS pCoolerSettings;
 
-      return speed;
+      pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS);
+
+      hm_NvAPI_GPU_GetCoolerSettings (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &pCoolerSettings);
+
+      return pCoolerSettings.Cooler[0].CurrentLevel;
       #endif
     }
+    #endif // HAVE_NVML || HAVE_NVAPI
   }
 
   return -1;
@@ -3177,48 +3182,54 @@ 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.hm_dll_amd)
+    if (data.hm_amd)
     {
       ADLPMActivity PMActivity;
 
       PMActivity.iSize = sizeof (ADLPMActivity);
 
-      if (hc_ADL_Overdrive_CurrentActivity_Get (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, &PMActivity) != ADL_OK) return -1;
+      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &PMActivity) != ADL_OK) return -1;
 
       return PMActivity.iActivityPercent;
     }
   }
-  else if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
+  #endif // HAVE_ADL
+
+  #if defined(HAVE_NVML) || defined(HAVE_NVAPI)
+  if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
   {
-    #ifdef LINUX
+    #if defined(LINUX) && defined(HAVE_NVML)
     nvmlUtilization_t utilization;
 
-    hc_NVML_nvmlDeviceGetUtilizationRates (data.hm_dll_nv, data.hm_device[device_id].adapter_index.nv, &utilization);
+    hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &utilization);
 
     return utilization.gpu;
     #endif
 
-    #ifdef WIN
+    #if defined(WIN) && defined(HAVE_NVAPI)
     NV_GPU_DYNAMIC_PSTATES_INFO_EX pDynamicPstatesInfoEx;
 
     pDynamicPstatesInfoEx.version = NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER;
 
-    if (hc_NvAPI_GPU_GetDynamicPstatesInfoEx (data.hm_device[device_id].adapter_index.nv, &pDynamicPstatesInfoEx) != NVAPI_OK) return -1;
+    if (hm_NvAPI_GPU_GetDynamicPstatesInfoEx (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &pDynamicPstatesInfoEx) != NVAPI_OK) return -1;
 
     return pDynamicPstatesInfoEx.utilization[0].percentage;
     #endif
   }
+  #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)
 {
   if (data.hm_device[device_id].fan_supported == 1)
   {
-    if (data.hm_dll_amd)
+    if (data.hm_amd)
     {
       if (data.hm_device[device_id].od_version == 5)
       {
@@ -3231,7 +3242,7 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
         lpFanSpeedValue.iFlags     = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
         lpFanSpeedValue.iFanSpeed  = fanspeed;
 
-        if (hc_ADL_Overdrive5_FanSpeed_Set (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive5_FanSpeed_Set (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
 
         return 0;
       }
@@ -3244,7 +3255,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 (hc_ADL_Overdrive6_FanSpeed_Set (data.hm_dll_amd, data.hm_device[device_id].adapter_index.amd, &fan_speed_value) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive6_FanSpeed_Set (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &fan_speed_value) != ADL_OK) return -1;
 
         return 0;
       }
@@ -3253,6 +3264,7 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
 
   return -1;
 }
+#endif
 
 // helper function for status display
 
@@ -3269,6 +3281,7 @@ void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int
     snprintf (target_buf, max_buf_size, "%2d%s", value, suffix);
   }
 }
+#endif // HAVE_HWMON
 
 /**
  * maskprocessor
@@ -3309,8 +3322,6 @@ void mp_add_cs_buf (uint *in_buf, size_t in_len, cs_t *css, int css_cnt)
 
   uint *css_uniq = (uint *) mymalloc (css_uniq_sz);
 
-  memset (css_uniq, 0, css_uniq_sz);
-
   size_t i;
 
   for (i = 0; i < cs->cs_len; i++)
@@ -3425,9 +3436,9 @@ void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, int mp_
   }
 }
 
-uint64_t mp_get_sum (uint css_cnt, cs_t *css)
+u64 mp_get_sum (uint css_cnt, cs_t *css)
 {
-  uint64_t sum = 1;
+  u64 sum = 1;
 
   for (uint css_pos = 0; css_pos < css_cnt; css_pos++)
   {
@@ -3544,12 +3555,12 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
   return (css);
 }
 
-void mp_exec (uint64_t val, char *buf, cs_t *css, int css_cnt)
+void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt)
 {
   for (int i = 0; i < css_cnt; i++)
   {
     uint len  = css[i].cs_len;
-    uint64_t next = val / len;
+    u64 next = val / len;
     uint pos  = val % len;
     buf[i] = (char) css[i].cs_buf[pos] & 0xff;
     val = next;
@@ -3574,9 +3585,7 @@ void mp_setup_sys (cs_t *mp_sys)
 {
   uint pos;
   uint chr;
-  uint donec[CHARSIZ];
-
-  memset (donec, 0, sizeof (donec));
+  uint donec[CHARSIZ] = { 0 };
 
   for (pos = 0, chr =  'a'; chr <=  'z'; chr++) { donec[chr] = 1;
                                                   mp_sys[0].cs_buf[pos++] = chr;
@@ -3611,9 +3620,7 @@ void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index)
   }
   else
   {
-    char mp_file[1024];
-
-    memset (mp_file, 0, sizeof (mp_file));
+    char mp_file[1024] = { 0 };
 
     size_t len = fread (mp_file, 1, sizeof (mp_file) - 1, fp);
 
@@ -3705,9 +3712,9 @@ char *mp_get_truncated_mask (char *mask_buf, size_t mask_len, uint len)
  * statprocessor
  */
 
-uint64_t sp_get_sum (uint start, uint stop, cs_t *root_css_buf)
+u64 sp_get_sum (uint start, uint stop, cs_t *root_css_buf)
 {
-  uint64_t sum = 1;
+  u64 sum = 1;
 
   uint i;
 
@@ -3719,9 +3726,9 @@ uint64_t sp_get_sum (uint start, uint stop, cs_t *root_css_buf)
   return (sum);
 }
 
-void sp_exec (uint64_t ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, uint start, uint stop)
+void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, uint start, uint stop)
 {
-  uint64_t v = ctx;
+  u64 v = ctx;
 
   cs_t *cs = &root_css_buf[start];
 
@@ -3729,8 +3736,8 @@ void sp_exec (uint64_t ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_b
 
   for (i = start; i < stop; i++)
   {
-    const uint64_t m = v % cs->cs_len;
-    const uint64_t d = v / cs->cs_len;
+    const u64 m = v % cs->cs_len;
+    const u64 d = v / cs->cs_len;
 
     v = d;
 
@@ -3760,11 +3767,11 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, uint disable, uint clas
    * Initialize hcstats
    */
 
-  uint64_t *root_stats_buf = (uint64_t *) mycalloc (SP_ROOT_CNT, sizeof (uint64_t));
+  u64 *root_stats_buf = (u64 *) mycalloc (SP_ROOT_CNT, sizeof (u64));
 
-  uint64_t *root_stats_ptr = root_stats_buf;
+  u64 *root_stats_ptr = root_stats_buf;
 
-  uint64_t *root_stats_buf_by_pos[SP_PW_MAX];
+  u64 *root_stats_buf_by_pos[SP_PW_MAX];
 
   for (i = 0; i < SP_PW_MAX; i++)
   {
@@ -3773,11 +3780,11 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, uint disable, uint clas
     root_stats_ptr += CHARSIZ;
   }
 
-  uint64_t *markov_stats_buf = (uint64_t *) mycalloc (SP_MARKOV_CNT, sizeof (uint64_t));
+  u64 *markov_stats_buf = (u64 *) mycalloc (SP_MARKOV_CNT, sizeof (u64));
 
-  uint64_t *markov_stats_ptr = markov_stats_buf;
+  u64 *markov_stats_ptr = markov_stats_buf;
 
-  uint64_t *markov_stats_buf_by_key[SP_PW_MAX][CHARSIZ];
+  u64 *markov_stats_buf_by_key[SP_PW_MAX][CHARSIZ];
 
   for (i = 0; i < SP_PW_MAX; i++)
   {
@@ -3795,9 +3802,7 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, uint disable, uint clas
 
   if (hcstat == NULL)
   {
-    char hcstat_tmp[256];
-
-    memset (hcstat_tmp, 0, sizeof (hcstat_tmp));
+    char hcstat_tmp[256] = { 0 };
 
     snprintf (hcstat_tmp, sizeof (hcstat_tmp) - 1, "%s/%s", shared_dir, SP_HCSTAT);
 
@@ -3813,17 +3818,21 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, uint disable, uint clas
     exit (-1);
   }
 
-  if (fread (root_stats_buf, sizeof (uint64_t), SP_ROOT_CNT, fd) != SP_ROOT_CNT)
+  if (fread (root_stats_buf, sizeof (u64), SP_ROOT_CNT, fd) != SP_ROOT_CNT)
   {
     log_error ("%s: Could not load data", hcstat);
 
+    fclose (fd);
+
     exit (-1);
   }
 
-  if (fread (markov_stats_buf, sizeof (uint64_t), SP_MARKOV_CNT, fd) != SP_MARKOV_CNT)
+  if (fread (markov_stats_buf, sizeof (u64), SP_MARKOV_CNT, fd) != SP_MARKOV_CNT)
   {
     log_error ("%s: Could not load data", hcstat);
 
+    fclose (fd);
+
     exit (-1);
   }
 
@@ -3835,8 +3844,8 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, uint disable, uint clas
 
   if (disable)
   {
-    memset (root_stats_buf,   0, SP_ROOT_CNT   * sizeof (uint64_t));
-    memset (markov_stats_buf, 0, SP_MARKOV_CNT * sizeof (uint64_t));
+    memset (root_stats_buf,   0, SP_ROOT_CNT   * sizeof (u64));
+    memset (markov_stats_buf, 0, SP_MARKOV_CNT * sizeof (u64));
   }
 
   if (classic)
@@ -3845,8 +3854,8 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, uint disable, uint clas
 
     for (i = 1; i < SP_PW_MAX; i++)
     {
-      uint64_t *out = root_stats_buf_by_pos[0];
-      uint64_t *in  = root_stats_buf_by_pos[i];
+      u64 *out = root_stats_buf_by_pos[0];
+      u64 *in  = root_stats_buf_by_pos[i];
 
       for (j = 0; j < CHARSIZ; j++)
       {
@@ -3856,8 +3865,8 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, uint disable, uint clas
 
     for (i = 1; i < SP_PW_MAX; i++)
     {
-      uint64_t *out = markov_stats_buf_by_key[0][0];
-      uint64_t *in  = markov_stats_buf_by_key[i][0];
+      u64 *out = markov_stats_buf_by_key[0][0];
+      u64 *in  = markov_stats_buf_by_key[i][0];
 
       for (j = 0; j < CHARSIZ; j++)
       {
@@ -3872,12 +3881,12 @@ void sp_setup_tbl (const char *shared_dir, char *hcstat, uint disable, uint clas
 
     for (i = 1; i < SP_PW_MAX; i++)
     {
-      memcpy (root_stats_buf_by_pos[i], root_stats_buf_by_pos[0], CHARSIZ * sizeof (uint64_t));
+      memcpy (root_stats_buf_by_pos[i], root_stats_buf_by_pos[0], CHARSIZ * sizeof (u64));
     }
 
     for (i = 1; i < SP_PW_MAX; i++)
     {
-      memcpy (markov_stats_buf_by_key[i][0], markov_stats_buf_by_key[0][0], CHARSIZ * CHARSIZ * sizeof (uint64_t));
+      memcpy (markov_stats_buf_by_key[i][0], markov_stats_buf_by_key[0][0], CHARSIZ * CHARSIZ * sizeof (u64));
     }
   }
 
@@ -4070,13 +4079,11 @@ void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out)
  * mixed shared functions
  */
 
-void dump_hex (const char *s, size_t size)
+void dump_hex (const u8 *s, const int sz)
 {
-  size_t i;
-
-  for (i = 0; i < size; i++)
+  for (int i = 0; i < sz; i++)
   {
-    log_info_nn ("%02x ", (unsigned char) s[i]);
+    log_info_nn ("%02x ", s[i]);
   }
 
   log_info ("");
@@ -4100,18 +4107,31 @@ char *get_exec_path ()
 
   #ifdef LINUX
 
-  char tmp[32];
+  char tmp[32] = { 0 };
 
-  sprintf (tmp, "/proc/%d/exe", getpid ());
+  snprintf (tmp, sizeof (tmp) - 1, "/proc/%d/exe", getpid ());
 
   const int len = readlink (tmp, exec_path, exec_path_len - 1);
 
-  #endif
-
-  #ifdef WIN
+  #elif WIN
 
   const int len = GetModuleFileName (NULL, exec_path, exec_path_len - 1);
 
+  #elif OSX
+
+  uint size = exec_path_len;
+
+  if (_NSGetExecutablePath (exec_path, &size) != 0)
+  {
+    log_error("! executable path buffer too small\n");
+
+    exit (-1);
+  }
+
+  const int len = strlen (exec_path);
+
+  #else
+  #error Your Operating System is not supported or detected
   #endif
 
   exec_path[len] = 0;
@@ -4145,9 +4165,11 @@ char *get_profile_dir (const char *homedir)
 {
   #define DOT_HASHCAT ".hashcat"
 
-  char *profile_dir = (char *) mymalloc (strlen (homedir) + 1 + strlen (DOT_HASHCAT) + 1);
+  size_t len = strlen (homedir) + 1 + strlen (DOT_HASHCAT) + 1;
 
-  sprintf (profile_dir, "%s/%s", homedir, DOT_HASHCAT);
+  char *profile_dir = (char *) mymalloc (len + 1);
+
+  snprintf (profile_dir, len, "%s/%s", homedir, DOT_HASHCAT);
 
   return profile_dir;
 }
@@ -4156,35 +4178,68 @@ char *get_session_dir (const char *profile_dir)
 {
   #define SESSIONS_FOLDER "sessions"
 
-  char *session_dir = (char *) mymalloc (strlen (profile_dir) + 1 + strlen (SESSIONS_FOLDER) + 1);
+  size_t len = strlen (profile_dir) + 1 + strlen (SESSIONS_FOLDER) + 1;
+
+  char *session_dir = (char *) mymalloc (len + 1);
 
-  sprintf (session_dir, "%s/%s", profile_dir, SESSIONS_FOLDER);
+  snprintf (session_dir, len, "%s/%s", profile_dir, SESSIONS_FOLDER);
 
   return session_dir;
 }
 
-void truecrypt_crc32 (char *file, unsigned char keytab[64])
+uint count_lines (FILE *fd)
 {
-  uint crc = ~0;
+  uint cnt = 0;
 
-  FILE *fd = fopen (file, "rb");
+  char *buf = (char *) mymalloc (BUFSIZ + 1);
 
-  if (fd == NULL)
+  char prev = '\n';
+
+  while (!feof (fd))
   {
-    log_error ("%s: %s", file, strerror (errno));
+    size_t nread = fread (buf, sizeof (char), BUFSIZ, fd);
 
-    exit (-1);
-  }
+    if (nread < 1) continue;
 
-  #define MAX_KEY_SIZE (1024 * 1024)
+    size_t i;
 
-  char *buf = (char *) mymalloc (MAX_KEY_SIZE);
+    for (i = 0; i < nread; i++)
+    {
+      if (prev == '\n') cnt++;
 
-  int nread = fread (buf, 1, MAX_KEY_SIZE, fd);
+      prev = buf[i];
+    }
+  }
 
-  int kpos = 0;
+  myfree (buf);
 
-  for (int fpos = 0; fpos < nread; fpos++)
+  return cnt;
+}
+
+void truecrypt_crc32 (const char *filename, u8 keytab[64])
+{
+  uint crc = ~0;
+
+  FILE *fd = fopen (filename, "rb");
+
+  if (fd == NULL)
+  {
+    log_error ("%s: %s", filename, strerror (errno));
+
+    exit (-1);
+  }
+
+  #define MAX_KEY_SIZE (1024 * 1024)
+
+  u8 *buf = (u8 *) mymalloc (MAX_KEY_SIZE + 1);
+
+  int nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd);
+
+  fclose (fd);
+
+  int kpos = 0;
+
+  for (int fpos = 0; fpos < nread; fpos++)
   {
     crc = crc32tab[(crc ^ buf[fpos]) & 0xff] ^ (crc >> 8);
 
@@ -4197,19 +4252,38 @@ void truecrypt_crc32 (char *file, unsigned char keytab[64])
   }
 
   myfree (buf);
+}
 
-  fclose(fd);
+#ifdef OSX
+int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t *cpu_set)
+{
+  int core;
+
+  for (core = 0; core < (8 * (int)cpu_size); core++)
+    if (CPU_ISSET(core, cpu_set)) break;
+
+  thread_affinity_policy_data_t policy = { core };
+
+  const int rc = thread_policy_set (pthread_mach_thread_np (thread), THREAD_AFFINITY_POLICY, (thread_policy_t) &policy, 1);
+
+  if (data.quiet == 0)
+  {
+    if (rc != KERN_SUCCESS)
+    {
+      log_error ("ERROR: %s : %d", "thread_policy_set()", rc);
+    }
+  }
+
+  return rc;
 }
+#endif
 
 void set_cpu_affinity (char *cpu_affinity)
 {
   #ifdef WIN
   DWORD_PTR aff_mask = 0;
-  #endif
-
-  #ifdef LINUX
+  #elif _POSIX
   cpu_set_t cpuset;
-
   CPU_ZERO (&cpuset);
   #endif
 
@@ -4227,9 +4301,7 @@ void set_cpu_affinity (char *cpu_affinity)
       {
         #ifdef WIN
         aff_mask = 0;
-        #endif
-
-        #ifdef LINUX
+        #elif _POSIX
         CPU_ZERO (&cpuset);
         #endif
 
@@ -4245,9 +4317,7 @@ void set_cpu_affinity (char *cpu_affinity)
 
       #ifdef WIN
       aff_mask |= 1 << (cpu_id - 1);
-      #endif
-
-      #ifdef LINUX
+      #elif _POSIX
       CPU_SET ((cpu_id - 1), &cpuset);
       #endif
 
@@ -4259,9 +4329,7 @@ void set_cpu_affinity (char *cpu_affinity)
   #ifdef WIN
   SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
   SetThreadAffinityMask (GetCurrentThread (), aff_mask);
-  #endif
-
-  #ifdef LINUX
+  #elif _POSIX
   pthread_t thread = pthread_self ();
   pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset);
   #endif
@@ -4295,7 +4363,7 @@ int sort_by_salt (const void *v1, const void *v2)
 
   uint n;
 
-  n = 12;
+  n = 16;
 
   while (n--)
   {
@@ -4325,7 +4393,7 @@ int sort_by_salt_buf (const void *v1, const void *v2)
   const salt_t *s1 = h1->salt;
   const salt_t *s2 = h2->salt;
 
-  uint n = 12;
+  uint n = 16;
 
   while (n--)
   {
@@ -4345,7 +4413,7 @@ int sort_by_hash_t_salt (const void *v1, const void *v2)
   const salt_t *s2 = h2->salt;
 
   // testphase: this should work
-  uint n = 12;
+  uint n = 16;
 
   while (n--)
   {
@@ -4378,8 +4446,8 @@ int sort_by_hash_t_salt_hccap (const void *v1, const void *v2)
   const salt_t *s1 = h1->salt;
   const salt_t *s2 = h2->salt;
 
-  // 12 - 2 (since last 2 uints contain the digest)
-  uint n = 10;
+  // 16 - 2 (since last 2 uints contain the digest)
+  uint n = 14;
 
   while (n--)
   {
@@ -4473,7 +4541,7 @@ int sort_by_dictstat (const void *s1, const void *s2)
   dictstat_t *d1 = (dictstat_t *) s1;
   dictstat_t *d2 = (dictstat_t *) s2;
 
-  #ifdef _POSIX
+  #ifdef LINUX
   d2->stat.st_atim = d1->stat.st_atim;
   #else
   d2->stat.st_atime = d1->stat.st_atime;
@@ -4492,8 +4560,8 @@ int sort_by_bitmap (const void *p1, const void *p2)
 
 int sort_by_digest_4_2 (const void *v1, const void *v2)
 {
-  const uint32_t *d1 = (const uint32_t *) v1;
-  const uint32_t *d2 = (const uint32_t *) v2;
+  const u32 *d1 = (const u32 *) v1;
+  const u32 *d2 = (const u32 *) v2;
 
   uint n = 2;
 
@@ -4508,8 +4576,8 @@ int sort_by_digest_4_2 (const void *v1, const void *v2)
 
 int sort_by_digest_4_4 (const void *v1, const void *v2)
 {
-  const uint32_t *d1 = (const uint32_t *) v1;
-  const uint32_t *d2 = (const uint32_t *) v2;
+  const u32 *d1 = (const u32 *) v1;
+  const u32 *d2 = (const u32 *) v2;
 
   uint n = 4;
 
@@ -4524,8 +4592,8 @@ int sort_by_digest_4_4 (const void *v1, const void *v2)
 
 int sort_by_digest_4_5 (const void *v1, const void *v2)
 {
-  const uint32_t *d1 = (const uint32_t *) v1;
-  const uint32_t *d2 = (const uint32_t *) v2;
+  const u32 *d1 = (const u32 *) v1;
+  const u32 *d2 = (const u32 *) v2;
 
   uint n = 5;
 
@@ -4540,8 +4608,8 @@ int sort_by_digest_4_5 (const void *v1, const void *v2)
 
 int sort_by_digest_4_6 (const void *v1, const void *v2)
 {
-  const uint32_t *d1 = (const uint32_t *) v1;
-  const uint32_t *d2 = (const uint32_t *) v2;
+  const u32 *d1 = (const u32 *) v1;
+  const u32 *d2 = (const u32 *) v2;
 
   uint n = 6;
 
@@ -4556,8 +4624,8 @@ int sort_by_digest_4_6 (const void *v1, const void *v2)
 
 int sort_by_digest_4_8 (const void *v1, const void *v2)
 {
-  const uint32_t *d1 = (const uint32_t *) v1;
-  const uint32_t *d2 = (const uint32_t *) v2;
+  const u32 *d1 = (const u32 *) v1;
+  const u32 *d2 = (const u32 *) v2;
 
   uint n = 8;
 
@@ -4572,8 +4640,8 @@ int sort_by_digest_4_8 (const void *v1, const void *v2)
 
 int sort_by_digest_4_16 (const void *v1, const void *v2)
 {
-  const uint32_t *d1 = (const uint32_t *) v1;
-  const uint32_t *d2 = (const uint32_t *) v2;
+  const u32 *d1 = (const u32 *) v1;
+  const u32 *d2 = (const u32 *) v2;
 
   uint n = 16;
 
@@ -4588,8 +4656,8 @@ int sort_by_digest_4_16 (const void *v1, const void *v2)
 
 int sort_by_digest_4_32 (const void *v1, const void *v2)
 {
-  const uint32_t *d1 = (const uint32_t *) v1;
-  const uint32_t *d2 = (const uint32_t *) v2;
+  const u32 *d1 = (const u32 *) v1;
+  const u32 *d2 = (const u32 *) v2;
 
   uint n = 32;
 
@@ -4604,8 +4672,8 @@ int sort_by_digest_4_32 (const void *v1, const void *v2)
 
 int sort_by_digest_4_64 (const void *v1, const void *v2)
 {
-  const uint32_t *d1 = (const uint32_t *) v1;
-  const uint32_t *d2 = (const uint32_t *) v2;
+  const u32 *d1 = (const u32 *) v1;
+  const u32 *d2 = (const u32 *) v2;
 
   uint n = 64;
 
@@ -4620,8 +4688,8 @@ int sort_by_digest_4_64 (const void *v1, const void *v2)
 
 int sort_by_digest_8_8 (const void *v1, const void *v2)
 {
-  const uint64_t *d1 = (const uint64_t *) v1;
-  const uint64_t *d2 = (const uint64_t *) v2;
+  const u64 *d1 = (const u64 *) v1;
+  const u64 *d2 = (const u64 *) v2;
 
   uint n = 8;
 
@@ -4636,8 +4704,8 @@ int sort_by_digest_8_8 (const void *v1, const void *v2)
 
 int sort_by_digest_8_16 (const void *v1, const void *v2)
 {
-  const uint64_t *d1 = (const uint64_t *) v1;
-  const uint64_t *d2 = (const uint64_t *) v2;
+  const u64 *d1 = (const u64 *) v1;
+  const u64 *d2 = (const u64 *) v2;
 
   uint n = 16;
 
@@ -4652,8 +4720,8 @@ int sort_by_digest_8_16 (const void *v1, const void *v2)
 
 int sort_by_digest_8_25 (const void *v1, const void *v2)
 {
-  const uint64_t *d1 = (const uint64_t *) v1;
-  const uint64_t *d2 = (const uint64_t *) v2;
+  const u64 *d1 = (const u64 *) v1;
+  const u64 *d2 = (const u64 *) v2;
 
   uint n = 25;
 
@@ -4668,8 +4736,8 @@ int sort_by_digest_8_25 (const void *v1, const void *v2)
 
 int sort_by_digest_p0p1 (const void *v1, const void *v2)
 {
-  const uint32_t *d1 = (const uint32_t *) v1;
-  const uint32_t *d2 = (const uint32_t *) v2;
+  const u32 *d1 = (const u32 *) v1;
+  const u32 *d2 = (const u32 *) v2;
 
   const uint dgst_pos0 = data.dgst_pos0;
   const uint dgst_pos1 = data.dgst_pos1;
@@ -4688,7 +4756,41 @@ int sort_by_digest_p0p1 (const void *v1, const void *v2)
   return (0);
 }
 
-void format_debug (char * debug_file, uint debug_mode, unsigned char *orig_plain_ptr, uint orig_plain_len, unsigned char *mod_plain_ptr, uint mod_plain_len, char *rule_buf, int rule_len)
+int sort_by_tuning_db_alias (const void *v1, const void *v2)
+{
+  const tuning_db_alias_t *t1 = (const tuning_db_alias_t *) v1;
+  const tuning_db_alias_t *t2 = (const tuning_db_alias_t *) v2;
+
+  const int res1 = strcmp (t1->device_name, t2->device_name);
+
+  if (res1 != 0) return (res1);
+
+  return 0;
+}
+
+int sort_by_tuning_db_entry (const void *v1, const void *v2)
+{
+  const tuning_db_entry_t *t1 = (const tuning_db_entry_t *) v1;
+  const tuning_db_entry_t *t2 = (const tuning_db_entry_t *) v2;
+
+  const int res1 = strcmp (t1->device_name, t2->device_name);
+
+  if (res1 != 0) return (res1);
+
+  const int res2 = t1->attack_mode
+                 - t2->attack_mode;
+
+  if (res2 != 0) return (res2);
+
+  const int res3 = t1->hash_type
+                 - t2->hash_type;
+
+  if (res3 != 0) return (res3);
+
+  return 0;
+}
+
+void format_debug (char *debug_file, uint debug_mode, unsigned char *orig_plain_ptr, uint orig_plain_len, unsigned char *mod_plain_ptr, uint mod_plain_len, char *rule_buf, int rule_len)
 {
   uint outfile_autohex = data.outfile_autohex;
 
@@ -4699,6 +4801,8 @@ void format_debug (char * debug_file, uint debug_mode, unsigned char *orig_plain
   if (debug_file != NULL)
   {
     debug_fp = fopen (debug_file, "ab");
+
+    lock_file (debug_fp);
   }
   else
   {
@@ -4774,7 +4878,7 @@ void format_plain (FILE *fp, unsigned char *plain_ptr, uint plain_len, uint outf
   }
 }
 
-void format_output (FILE *out_fp, char *out_buf, unsigned char *plain_ptr, const uint plain_len, const uint64_t crackpos, unsigned char *username, const uint user_len)
+void format_output (FILE *out_fp, char *out_buf, unsigned char *plain_ptr, const uint plain_len, const u64 crackpos, unsigned char *username, const uint user_len)
 {
   uint outfile_format = data.outfile_format;
 
@@ -4836,7 +4940,7 @@ void format_output (FILE *out_fp, char *out_buf, unsigned char *plain_ptr, const
 
     #ifdef _POSIX
     #ifdef __x86_64__
-    fprintf (out_fp, "%lu", crackpos);
+    fprintf (out_fp, "%lu", (unsigned long) crackpos);
     #else
     fprintf (out_fp, "%llu", crackpos);
     #endif
@@ -5074,9 +5178,7 @@ void handle_left_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int inpu
 
   uint user_len = input_len - 32;
 
-  char hash_output[user_len + 33];
-
-  memset (hash_output, 0, sizeof (hash_output));
+  char *hash_output = (char *) mymalloc (33);
 
   memcpy (hash_output, input_buf, input_len);
 
@@ -5100,6 +5202,8 @@ void handle_left_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int inpu
 
   format_output (out_fp, hash_output, NULL, 0, 0, NULL, 0);
 
+  myfree (hash_output);
+
   if (weak_hash_found == 1) myfree (pot_right_ptr);
 }
 
@@ -5117,7 +5221,7 @@ uint setup_opencl_platforms_filter (char *opencl_platforms)
     {
       int platform = atoi (next);
 
-      if (platform < 1 || platform > 31)
+      if (platform < 1 || platform > 32)
       {
         log_error ("ERROR: invalid OpenCL platform %u specified", platform);
 
@@ -5138,94 +5242,98 @@ uint setup_opencl_platforms_filter (char *opencl_platforms)
   return opencl_platforms_filter;
 }
 
-cl_device_type setup_device_types_filter (char *opencl_device_types)
+u32 setup_devices_filter (char *opencl_devices)
 {
-  cl_device_type device_types_filter = 0;
+  u32 devices_filter = 0;
 
-  if (opencl_device_types)
+  if (opencl_devices)
   {
-    char *device_types = strdup (opencl_device_types);
+    char *devices = strdup (opencl_devices);
 
-    char *next = strtok (device_types, ",");
+    char *next = strtok (devices, ",");
 
     do
     {
-      int device_type = atoi (next);
+      int device_id = atoi (next);
 
-      if (device_type < 1 || device_type > 3)
+      if (device_id < 1 || device_id > 32)
       {
-        log_error ("ERROR: invalid device_type %u specified", device_type);
+        log_error ("ERROR: invalid device_id %u specified", device_id);
 
         exit (-1);
       }
 
-      device_types_filter |= 1 << device_type;
+      devices_filter |= 1 << (device_id - 1);
 
     } while ((next = strtok (NULL, ",")) != NULL);
 
-    free (device_types);
+    free (devices);
   }
   else
   {
-    // Do not use CPU by default, this often reduces GPU performance because
-    // the CPU is to busy to handle GPU synchronization
-
-    device_types_filter = CL_DEVICE_TYPE_ALL & ~CL_DEVICE_TYPE_CPU;
+    devices_filter = -1;
   }
 
-  return device_types_filter;
+  return devices_filter;
 }
 
-uint devices_to_devicemask (char *opencl_devices)
+cl_device_type setup_device_types_filter (char *opencl_device_types)
 {
-  uint opencl_devicemask = 0;
+  cl_device_type device_types_filter = 0;
 
-  if (opencl_devices)
+  if (opencl_device_types)
   {
-    char *devices = strdup (opencl_devices);
+    char *device_types = strdup (opencl_device_types);
 
-    char *next = strtok (devices, ",");
+    char *next = strtok (device_types, ",");
 
     do
     {
-      uint device_id = atoi (next);
+      int device_type = atoi (next);
 
-      if (device_id < 1 || device_id > 8)
+      if (device_type < 1 || device_type > 3)
       {
-        log_error ("ERROR: invalid device_id %u specified", device_id);
+        log_error ("ERROR: invalid device_type %u specified", device_type);
 
         exit (-1);
       }
 
-      opencl_devicemask |= 1 << (device_id - 1);
+      device_types_filter |= 1 << device_type;
 
     } while ((next = strtok (NULL, ",")) != NULL);
 
-    free (devices);
+    free (device_types);
+  }
+  else
+  {
+    // Do not use CPU by default, this often reduces GPU performance because
+    // the CPU is too busy to handle GPU synchronization
+
+    device_types_filter = CL_DEVICE_TYPE_ALL & ~CL_DEVICE_TYPE_CPU;
   }
 
-  return opencl_devicemask;
+  return device_types_filter;
 }
 
-uint get_random_num (uint min, uint max)
+u32 get_random_num (const u32 min, const u32 max)
 {
   if (min == max) return (min);
 
-  return (uint) ((rand () % (max - min)) + min);
+  return ((rand () % (max - min)) + min);
 }
 
-uint32_t mydivc32 (const uint32_t dividend, const uint32_t divisor)
+u32 mydivc32 (const u32 dividend, const u32 divisor)
 {
-  uint32_t quotient = dividend / divisor;
+  u32 quotient = dividend / divisor;
 
   if (dividend % divisor) quotient++;
 
   return quotient;
 }
 
-uint64_t mydivc64 (const uint64_t dividend, const uint64_t divisor)
+u64 mydivc64 (const u64 dividend, const u64 divisor)
 {
-  uint64_t quotient = dividend / divisor;
+  u64 quotient = dividend / divisor;
 
   if (dividend % divisor) quotient++;
 
@@ -5307,12 +5415,12 @@ void format_speed_display (float val, char *buf, size_t len)
   }
 }
 
-void lowercase (char *buf, int len)
+void lowercase (u8 *buf, int len)
 {
   for (int i = 0; i < len; i++) buf[i] = tolower (buf[i]);
 }
 
-void uppercase (char *buf, int len)
+void uppercase (u8 *buf, int len)
 {
   for (int i = 0; i < len; i++) buf[i] = toupper (buf[i]);
 }
@@ -5402,14 +5510,31 @@ char **scan_directory (const char *path)
 
   int num_files = 0;
 
-  DIR *d;
+  DIR *d = NULL;
 
   if ((d = opendir (tmp_path)) != NULL)
   {
+    #ifdef OSX
+    struct dirent e;
+
+    for (;;) {
+      memset (&e, 0, sizeof (e));
+      struct dirent *de = NULL;
+
+      if (readdir_r (d, &e, &de) != 0)
+      {
+        log_error ("ERROR: readdir_r() failed");
+
+        break;
+      }
+
+      if (de == NULL) break;
+    #else
     struct dirent *de;
 
     while ((de = readdir (d)) != NULL)
     {
+    #endif
       if ((strcmp (de->d_name, ".") == 0) || (strcmp (de->d_name, "..") == 0)) continue;
 
       int path_size = strlen (tmp_path) + 1 + strlen (de->d_name);
@@ -5492,6 +5617,10 @@ 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_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;
+    case OPTI_TYPE_USES_BITS_64:      return ((char *) OPTI_STR_USES_BITS_64);      break;
   }
 
   return (NULL);
@@ -5705,6 +5834,7 @@ char *strhashtype (const uint hash_mode)
     case 12800: return ((char *) HT_12800); break;
     case 12900: return ((char *) HT_12900); break;
     case 13000: return ((char *) HT_13000); break;
+    case 13100: return ((char *) HT_13100); break;
   }
 
   return ((char *) "Unknown");
@@ -5724,6 +5854,7 @@ char *strstatus (const uint devices_status)
     case  STATUS_QUIT:               return ((char *) ST_0007); break;
     case  STATUS_BYPASS:             return ((char *) ST_0008); break;
     case  STATUS_STOP_AT_CHECKPOINT: return ((char *) ST_0009); break;
+    case  STATUS_AUTOTUNE:           return ((char *) ST_0010); break;
   }
 
   return ((char *) "Unknown");
@@ -5742,9 +5873,9 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
   uint len = 4096;
 
-  uint digest_buf[64];
+  uint digest_buf[64] = { 0 };
 
-  uint64_t *digest_buf64 = (uint64_t *) digest_buf;
+  u64 *digest_buf64 = (u64 *) digest_buf;
 
   char *digests_buf_ptr = (char *) data.digests_buf;
 
@@ -5761,8 +5892,8 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
         break;
 
       case HASH_TYPE_DESRACF:
-        digest_buf[0] = ROTATE_LEFT (digest_buf[0], 29);
-        digest_buf[1] = ROTATE_LEFT (digest_buf[1], 29);
+        digest_buf[0] = rotl32 (digest_buf[0], 29);
+        digest_buf[1] = rotl32 (digest_buf[1], 29);
 
         FP (digest_buf[1], digest_buf[0], tt);
         break;
@@ -5772,18 +5903,18 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
         break;
 
       case HASH_TYPE_NETNTLM:
-        digest_buf[0] = ROTATE_LEFT (digest_buf[0], 29);
-        digest_buf[1] = ROTATE_LEFT (digest_buf[1], 29);
-        digest_buf[2] = ROTATE_LEFT (digest_buf[2], 29);
-        digest_buf[3] = ROTATE_LEFT (digest_buf[3], 29);
+        digest_buf[0] = rotl32 (digest_buf[0], 29);
+        digest_buf[1] = rotl32 (digest_buf[1], 29);
+        digest_buf[2] = rotl32 (digest_buf[2], 29);
+        digest_buf[3] = rotl32 (digest_buf[3], 29);
 
         FP (digest_buf[1], digest_buf[0], tt);
         FP (digest_buf[3], digest_buf[2], tt);
         break;
 
       case HASH_TYPE_BSDICRYPT:
-        digest_buf[0] = ROTATE_LEFT (digest_buf[0], 31);
-        digest_buf[1] = ROTATE_LEFT (digest_buf[1], 31);
+        digest_buf[0] = rotl32 (digest_buf[0], 31);
+        digest_buf[1] = rotl32 (digest_buf[1], 31);
 
         FP (digest_buf[1], digest_buf[0], tt);
         break;
@@ -5926,8 +6057,8 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
       {
         case HASH_TYPE_NETNTLM:
 
-          salt.salt_buf[0] = ROTATE_RIGHT (salt.salt_buf[0], 3);
-          salt.salt_buf[1] = ROTATE_RIGHT (salt.salt_buf[1], 3);
+          salt.salt_buf[0] = rotr32 (salt.salt_buf[0], 3);
+          salt.salt_buf[1] = rotr32 (salt.salt_buf[1], 3);
 
           FP (salt.salt_buf[1], salt.salt_buf[0], tt);
 
@@ -5959,9 +6090,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     if (opts_type & OPTS_TYPE_ST_HEX)
     {
-      char tmp[64];
-
-      memset (tmp, 0, sizeof (tmp));
+      char tmp[64] = { 0 };
 
       for (uint i = 0, j = 0; i < len; i += 1, j += 2)
       {
@@ -5984,30 +6113,23 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   // some modes require special encoding
   //
 
-  uint out_buf_plain[256];
-  uint out_buf_salt[256];
+  uint out_buf_plain[256] = { 0 };
+  uint out_buf_salt[256] = { 0 };
 
-  char tmp_buf[1024];
-
-  memset (out_buf_plain, 0, sizeof (out_buf_plain));
-  memset (out_buf_salt,  0, sizeof (out_buf_salt));
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  char tmp_buf[1024] = { 0 };
 
   char *ptr_plain = (char *) out_buf_plain;
   char *ptr_salt  = (char *) out_buf_salt;
 
   if (hash_mode == 22)
   {
-    char username[30];
-
-    memset (username, 0, sizeof (username));
+    char username[30] = { 0 };
 
     memcpy (username, salt.salt_buf, salt.salt_len - 22);
 
     char sig[6] = { 'n', 'r', 'c', 's', 't', 'n' };
 
-    uint16_t *ptr = (uint16_t *) digest_buf;
+    u16 *ptr = (u16 *) digest_buf;
 
     tmp_buf[ 0] = sig[0];
     tmp_buf[ 1] = int_to_base64 (((ptr[1]) >> 12) & 0x3f);
@@ -6061,7 +6183,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 101)
   {
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
@@ -6071,13 +6193,13 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     memcpy (tmp_buf, digest_buf, 20);
 
-    base64_encode (int_to_base64, tmp_buf, 20, ptr_plain);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, 20, (u8 *) ptr_plain);
 
     snprintf (out_buf, len-1, "{SHA}%s", ptr_plain);
   }
   else if (hash_mode == 111)
   {
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
@@ -6088,14 +6210,14 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
     memcpy (tmp_buf, digest_buf, 20);
     memcpy (tmp_buf + 20, salt.salt_buf, salt.salt_len);
 
-    base64_encode (int_to_base64, tmp_buf, 20 + salt.salt_len, ptr_plain);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, 20 + salt.salt_len, (u8 *) ptr_plain);
 
     snprintf (out_buf, len-1, "{SSHA}%s", ptr_plain);
   }
   else if (hash_mode == 122)
   {
     snprintf (out_buf, len-1, "%s%08x%08x%08x%08x%08x",
-      (unsigned char *) salt.salt_buf,
+      (char *) salt.salt_buf,
       digest_buf[0],
       digest_buf[1],
       digest_buf[2],
@@ -6105,7 +6227,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   else if (hash_mode == 124)
   {
     snprintf (out_buf, len-1, "sha1$%s$%08x%08x%08x%08x%08x",
-      (unsigned char *) salt.salt_buf,
+      (char *) salt.salt_buf,
       digest_buf[0],
       digest_buf[1],
       digest_buf[2],
@@ -6115,7 +6237,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   else if (hash_mode == 131)
   {
     snprintf (out_buf, len-1, "0x0100%s%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x",
-      (unsigned char *) salt.salt_buf,
+      (char *) salt.salt_buf,
       0, 0, 0, 0, 0,
       digest_buf[0],
       digest_buf[1],
@@ -6126,7 +6248,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   else if (hash_mode == 132)
   {
     snprintf (out_buf, len-1, "0x0100%s%08x%08x%08x%08x%08x",
-      (unsigned char *) salt.salt_buf,
+      (char *) salt.salt_buf,
       digest_buf[0],
       digest_buf[1],
       digest_buf[2],
@@ -6135,7 +6257,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 133)
   {
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
@@ -6145,7 +6267,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     memcpy (tmp_buf, digest_buf, 20);
 
-    base64_encode (int_to_base64, tmp_buf, 20, ptr_plain);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, 20, (u8 *) ptr_plain);
 
     snprintf (out_buf, len-1, "%s", ptr_plain);
   }
@@ -6153,11 +6275,11 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   {
     memcpy (tmp_buf, salt.salt_buf, salt.salt_len);
 
-    base64_encode (int_to_base64, tmp_buf, salt.salt_len, ptr_salt);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, salt.salt_len, (u8 *) ptr_salt);
 
     memset (tmp_buf, 0, sizeof (tmp_buf));
 
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
@@ -6167,7 +6289,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     memcpy (tmp_buf, digest_buf, 20);
 
-    base64_encode (int_to_base64, tmp_buf, 20, ptr_plain);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, 20, (u8 *) ptr_plain);
 
     ptr_plain[27] = 0;
 
@@ -6175,7 +6297,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 400)
   {
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
@@ -6188,7 +6310,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 500)
   {
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
@@ -6217,7 +6339,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 1421)
   {
-    uint8_t *salt_ptr = (uint8_t *) salt.salt_buf;
+    u8 *salt_ptr = (u8 *) salt.salt_buf;
 
     snprintf (out_buf, len-1, "%c%c%c%c%c%c%08x%08x%08x%08x%08x%08x%08x%08x",
       salt_ptr[0],
@@ -6239,11 +6361,11 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   {
     memcpy (tmp_buf, salt.salt_buf, salt.salt_len);
 
-    base64_encode (int_to_base64, tmp_buf, salt.salt_len, ptr_salt);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, salt.salt_len, (u8 *) ptr_salt);
 
     memset (tmp_buf, 0, sizeof (tmp_buf));
 
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
@@ -6256,7 +6378,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     memcpy (tmp_buf, digest_buf, 32);
 
-    base64_encode (int_to_base64, tmp_buf, 32, ptr_plain);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, 32, (u8 *) ptr_plain);
 
     ptr_plain[43] = 0;
 
@@ -6272,14 +6394,14 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     memset (tmp_buf, 0, sizeof (tmp_buf));
 
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
 
     memcpy (tmp_buf, digest_buf, 8);
 
-    base64_encode (int_to_itoa64, tmp_buf, 8, ptr_plain);
+    base64_encode (int_to_itoa64, (const u8 *) tmp_buf, 8, (u8 *) ptr_plain);
 
     snprintf (out_buf + 2, len-1-2, "%s", ptr_plain);
 
@@ -6287,7 +6409,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 1600)
   {
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
@@ -6321,7 +6443,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
     memcpy (tmp_buf, digest_buf, 64);
     memcpy (tmp_buf + 64, salt.salt_buf, salt.salt_len);
 
-    base64_encode (int_to_base64, tmp_buf, 64 + salt.salt_len, ptr_plain);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, 64 + salt.salt_len, (u8 *) ptr_plain);
 
     snprintf (out_buf, len-1, "%s%s", SIGNATURE_SHA512B64S, ptr_plain);
   }
@@ -6441,7 +6563,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     wpa_t *wpa = &wpas[salt_pos];
 
-    uint pke[25];
+    uint pke[25] = { 0 };
 
     char *pke_ptr = (char *) pke;
 
@@ -6450,8 +6572,8 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
       pke[i] = byte_swap_32 (wpa->pke[i]);
     }
 
-    unsigned char mac1[6];
-    unsigned char mac2[6];
+    unsigned char mac1[6] = { 0 };
+    unsigned char mac2[6] = { 0 };
 
     memcpy (mac1, pke_ptr + 23, 6);
     memcpy (mac2, pke_ptr + 29, 6);
@@ -6490,7 +6612,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 4800)
   {
-    uint8_t chap_id_byte = (uint8_t) salt.salt_buf[4];
+    u8 chap_id_byte = (u8) salt.salt_buf[4];
 
     snprintf (out_buf, len-1, "%08x%08x%08x%08x:%08x%08x%08x%08x:%02x",
       digest_buf[0],
@@ -6660,15 +6782,10 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     netntlm_t *netntlm = &netntlms[salt_pos];
 
-    char user_buf[64];
-    char domain_buf[64];
-    char srvchall_buf[1024];
-    char clichall_buf[1024];
-
-    memset (user_buf,     0, sizeof (user_buf));
-    memset (domain_buf,   0, sizeof (domain_buf));
-    memset (srvchall_buf, 0, sizeof (srvchall_buf));
-    memset (clichall_buf, 0, sizeof (clichall_buf));
+    char user_buf[64] = { 0 };
+    char domain_buf[64] = { 0 };
+    char srvchall_buf[1024] = { 0 };
+    char clichall_buf[1024] = { 0 };
 
     for (uint i = 0, j = 0; j < netntlm->user_len; i += 1, j += 2)
     {
@@ -6686,16 +6803,16 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     for (uint i = 0, j = 0; i < netntlm->srvchall_len; i += 1, j += 2)
     {
-      char *ptr = (char *) netntlm->chall_buf;
+      u8 *ptr = (u8 *) netntlm->chall_buf;
 
-      sprintf (srvchall_buf + j, "%02x", (uint8_t) ptr[i]);
+      sprintf (srvchall_buf + j, "%02x", ptr[i]);
     }
 
     for (uint i = 0, j = 0; i < netntlm->clichall_len; i += 1, j += 2)
     {
-      char *ptr = (char *) netntlm->chall_buf;
+      u8 *ptr = (u8 *) netntlm->chall_buf;
 
-      sprintf (clichall_buf + j, "%02x", (uint8_t) ptr[netntlm->srvchall_len + i]);
+      sprintf (clichall_buf + j, "%02x", ptr[netntlm->srvchall_len + i]);
     }
 
     snprintf (out_buf, len-1, "%s::%s:%s:%08x%08x%08x%08x%08x%08x:%s",
@@ -6716,15 +6833,10 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     netntlm_t *netntlm = &netntlms[salt_pos];
 
-    char user_buf[64];
-    char domain_buf[64];
-    char srvchall_buf[1024];
-    char clichall_buf[1024];
-
-    memset (user_buf,     0, sizeof (user_buf));
-    memset (domain_buf,   0, sizeof (domain_buf));
-    memset (srvchall_buf, 0, sizeof (srvchall_buf));
-    memset (clichall_buf, 0, sizeof (clichall_buf));
+    char user_buf[64] = { 0 };
+    char domain_buf[64] = { 0 };
+    char srvchall_buf[1024] = { 0 };
+    char clichall_buf[1024] = { 0 };
 
     for (uint i = 0, j = 0; j < netntlm->user_len; i += 1, j += 2)
     {
@@ -6742,16 +6854,16 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     for (uint i = 0, j = 0; i < netntlm->srvchall_len; i += 1, j += 2)
     {
-      char *ptr = (char *) netntlm->chall_buf;
+      u8 *ptr = (u8 *) netntlm->chall_buf;
 
-      sprintf (srvchall_buf + j, "%02x", (uint8_t) ptr[i]);
+      sprintf (srvchall_buf + j, "%02x", ptr[i]);
     }
 
     for (uint i = 0, j = 0; i < netntlm->clichall_len; i += 1, j += 2)
     {
-      char *ptr = (char *) netntlm->chall_buf;
+      u8 *ptr = (u8 *) netntlm->chall_buf;
 
-      sprintf (clichall_buf + j, "%02x", (uint8_t) ptr[netntlm->srvchall_len + i]);
+      sprintf (clichall_buf + j, "%02x", ptr[netntlm->srvchall_len + i]);
     }
 
     snprintf (out_buf, len-1, "%s::%s:%s:%08x%08x%08x%08x:%s",
@@ -6779,7 +6891,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     memcpy (tmp_buf, digest_buf, 32);
 
-    base64_encode (int_to_itoa64, tmp_buf, 32, ptr_plain);
+    base64_encode (int_to_itoa64, (const u8 *) tmp_buf, 32, (u8 *) ptr_plain);
 
     ptr_plain[43] = 0;
 
@@ -6806,7 +6918,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 6300)
   {
-    // the encoder is a bit to intelligent, it expects the input data in the wrong BOM
+    // the encoder is a bit too intelligent, it expects the input data in the wrong BOM
 
     digest_buf[0] = byte_swap_32 (digest_buf[0]);
     digest_buf[1] = byte_swap_32 (digest_buf[1]);
@@ -6868,7 +6980,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     pbkdf2_sha512_t *pbkdf2_sha512  = &pbkdf2_sha512s[salt_pos];
 
-    uint esalt[16];
+    uint esalt[8] = { 0 };
 
     esalt[0] = byte_swap_32 (pbkdf2_sha512->salt_buf[0]);
     esalt[1] = byte_swap_32 (pbkdf2_sha512->salt_buf[1]);
@@ -6974,10 +7086,10 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     krb5pa_t *krb5pa = &krb5pas[salt_pos];
 
-    uint8_t *ptr_timestamp = (uint8_t *) krb5pa->timestamp;
-    uint8_t *ptr_checksum  = (uint8_t *) krb5pa->checksum;
+    u8 *ptr_timestamp = (u8 *) krb5pa->timestamp;
+    u8 *ptr_checksum  = (u8 *) krb5pa->checksum;
 
-    char data[128];
+    char data[128] = { 0 };
 
     char *ptr_data = data;
 
@@ -7065,7 +7177,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     cloudkey_t *cloudkey = &cloudkeys[salt_pos];
 
-    char data_buf[4096];
+    char data_buf[4096] = { 0 };
 
     for (int i = 0, j = 0; i < 512; i += 1, j += 8)
     {
@@ -7106,11 +7218,9 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 8300)
   {
-    // todo
-
-    char digest_buf_c[33];
+    char digest_buf_c[34] = { 0 };
 
-    base32_encode (int_to_itoa32, (char *) digest_buf, 32, digest_buf_c);
+    base32_encode (int_to_itoa32, (const u8 *) digest_buf, 20, (u8 *) digest_buf_c);
 
     digest_buf_c[32] = 0;
 
@@ -7118,7 +7228,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     const uint salt_pc_len = salt.salt_buf_pc[7]; // what a hack
 
-    char domain_buf_c[33];
+    char domain_buf_c[33] = { 0 };
 
     memcpy (domain_buf_c, (char *) salt.salt_buf_pc, salt_pc_len);
 
@@ -7171,7 +7281,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     androidfde_t *androidfde = &androidfdes[salt_pos];
 
-    char tmp[3073];
+    char tmp[3073] = { 0 };
 
     for (uint i = 0, j = 0; i < 384; i += 1, j += 8)
     {
@@ -7198,11 +7308,9 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
     uint r = salt.scrypt_r;
     uint p = salt.scrypt_p;
 
-    char base64_salt[32];
+    char base64_salt[32] = { 0 };
 
-    memset (base64_salt, 0, 32);
-
-    base64_encode (int_to_base64, (char *) salt.salt_buf, salt.salt_len, base64_salt +  0);
+    base64_encode (int_to_base64, (const u8 *) salt.salt_buf, salt.salt_len, (u8 *) base64_salt);
 
     memset (tmp_buf, 0, 46);
 
@@ -7216,7 +7324,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
     digest_buf[7] = byte_swap_32 (digest_buf[7]);
     digest_buf[8] = 0; // needed for base64_encode ()
 
-    base64_encode (int_to_base64, (char *) digest_buf, 32, tmp_buf +  0);
+    base64_encode (int_to_base64, (const u8 *) digest_buf, 32, (u8 *) tmp_buf);
 
     snprintf (out_buf, len-1, "%s:%i:%i:%i:%s:%s",
       SIGNATURE_SCRYPT,
@@ -7252,10 +7360,9 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
     digest_buf[7] = byte_swap_32 (digest_buf[7]);
     digest_buf[8] = 0; // needed for base64_encode ()
 
-    char tmp_buf[64];
-    memset (tmp_buf, 0, sizeof (tmp_buf));
+    char tmp_buf[64] = { 0 };
 
-    base64_encode (int_to_itoa64, (char *) digest_buf, 32, tmp_buf);
+    base64_encode (int_to_itoa64, (const u8 *) digest_buf, 32, (u8 *) tmp_buf);
     tmp_buf[43] = 0; // cut it here
 
     // output
@@ -7274,10 +7381,9 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
     digest_buf[7] = byte_swap_32 (digest_buf[7]);
     digest_buf[8] = 0; // needed for base64_encode ()
 
-    char tmp_buf[64];
-    memset (tmp_buf, 0, sizeof (tmp_buf));
+    char tmp_buf[64] = { 0 };
 
-    base64_encode (int_to_itoa64, (char *) digest_buf, 32, tmp_buf);
+    base64_encode (int_to_itoa64, (const u8 *) digest_buf, 32, (u8 *) tmp_buf);
     tmp_buf[43] = 0; // cut it here
 
     unsigned char *salt_buf_ptr = (unsigned char *) salt.salt_buf;
@@ -7408,7 +7514,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     oldoffice01_t *oldoffice01 = &oldoffice01s[salt_pos];
 
-    uint8_t *rc4key = (uint8_t *) oldoffice01->rc4key;
+    u8 *rc4key = (u8 *) oldoffice01->rc4key;
 
     snprintf (out_buf, len-1, "%s*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x:%02x%02x%02x%02x%02x",
       (oldoffice01->version == 0) ? SIGNATURE_OLDOFFICE0 : SIGNATURE_OLDOFFICE1,
@@ -7480,7 +7586,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     oldoffice34_t *oldoffice34 = &oldoffice34s[salt_pos];
 
-    uint8_t *rc4key = (uint8_t *) oldoffice34->rc4key;
+    u8 *rc4key = (u8 *) oldoffice34->rc4key;
 
     snprintf (out_buf, len-1, "%s*%08x%08x%08x%08x*%08x%08x%08x%08x*%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x",
       (oldoffice34->version == 3) ? SIGNATURE_OLDOFFICE3 : SIGNATURE_OLDOFFICE4,
@@ -7525,10 +7631,9 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
     digest_buf[7] = byte_swap_32 (digest_buf[7]);
     digest_buf[8] = 0; // needed for base64_encode ()
 
-    char tmp_buf[64];
-    memset (tmp_buf, 0, sizeof (tmp_buf));
+    char tmp_buf[64] = { 0 };
 
-    base64_encode (int_to_base64, (char *) digest_buf, 32, tmp_buf);
+    base64_encode (int_to_base64, (const u8 *) digest_buf, 32, (u8 *) tmp_buf);
 
     // output
 
@@ -7554,15 +7659,13 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     // challenge
 
-    char challenge[100];
-
-    memset (challenge, 0, sizeof (challenge));
+    char challenge[100] = { 0 };
 
-    base64_encode (int_to_base64, (char *) salt.salt_buf, salt.salt_len, challenge);
+    base64_encode (int_to_base64, (const u8 *) salt.salt_buf, salt.salt_len, (u8 *) challenge);
 
     // response
 
-    char tmp_buf[100];
+    char tmp_buf[100] = { 0 };
 
     uint tmp_len = snprintf (tmp_buf, 100, "%s %08x%08x%08x%08x",
       (char *) cram_md5->user,
@@ -7571,19 +7674,15 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
       digest_buf[2],
       digest_buf[3]);
 
-    char response[100];
+    char response[100] = { 0 };
 
-    memset (response, 0, sizeof (response));
-
-    base64_encode (int_to_base64, (char *) tmp_buf, tmp_len, response);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, tmp_len, (u8 *) response);
 
     snprintf (out_buf, len-1, "%s%s$%s", SIGNATURE_CRAM_MD5, challenge, response);
   }
   else if (hash_mode == 10300)
   {
-    char tmp_buf[100];
-
-    memset (tmp_buf, 0, sizeof (tmp_buf));
+    char tmp_buf[100] = { 0 };
 
     memcpy (tmp_buf +  0, digest_buf, 20);
     memcpy (tmp_buf + 20, salt.salt_buf, salt.salt_len);
@@ -7592,11 +7691,9 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     // base64 encode it
 
-    char base64_encoded[100];
+    char base64_encoded[100] = { 0 };
 
-    memset (base64_encoded, 0, sizeof (base64_encoded));
-
-    base64_encode (int_to_base64, (char *) tmp_buf, tmp_len, base64_encoded);
+    base64_encode (int_to_base64, (const u8 *) tmp_buf, tmp_len, (u8 *) base64_encoded);
 
     snprintf (out_buf, len-1, "%s%i}%s", SIGNATURE_SAPH_SHA1, salt.salt_iter + 1, base64_encoded);
   }
@@ -7682,7 +7779,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     pdf_t *pdf = &pdfs[salt_pos];
 
-    uint8_t *rc4key = (uint8_t *) pdf->rc4key;
+    u8 *rc4key = (u8 *) pdf->rc4key;
 
     snprintf (out_buf, len-1, "$pdf$%d*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x*%d*%08x%08x%08x%08x%08x%08x%08x%08x:%02x%02x%02x%02x%02x",
 
@@ -7829,7 +7926,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 11100)
   {
-    uint32_t salt_challenge = salt.salt_buf[0];
+    u32 salt_challenge = salt.salt_buf[0];
 
     salt_challenge = byte_swap_32 (salt_challenge);
 
@@ -7871,21 +7968,21 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     for (uint i = 0, j = 0; i < cry_master_len; i += 1, j += 2)
     {
-      const uint8_t *ptr = (const uint8_t *) bitcoin_wallet->cry_master_buf;
+      const u8 *ptr = (const u8 *) bitcoin_wallet->cry_master_buf;
 
       sprintf (cry_master_buf + j, "%02x", ptr[i]);
     }
 
     for (uint i = 0, j = 0; i < ckey_len; i += 1, j += 2)
     {
-      const uint8_t *ptr = (const uint8_t *) bitcoin_wallet->ckey_buf;
+      const u8 *ptr = (const u8 *) bitcoin_wallet->ckey_buf;
 
       sprintf (ckey_buf + j, "%02x", ptr[i]);
     }
 
     for (uint i = 0, j = 0; i < public_key_len; i += 1, j += 2)
     {
-      const uint8_t *ptr = (const uint8_t *) bitcoin_wallet->public_key_buf;
+      const u8 *ptr = (const u8 *) bitcoin_wallet->public_key_buf;
 
       sprintf (public_key_buf + j, "%02x", ptr[i]);
     }
@@ -7928,7 +8025,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     for (uint i = 0, j = 0; i < data_len; i += 1, j += 2)
     {
-      const uint8_t *ptr = (const uint8_t *) seven_zip->data_buf;
+      const u8 *ptr = (const u8 *) seven_zip->data_buf;
 
       sprintf (data_buf + j, "%02x", ptr[i]);
     }
@@ -8045,7 +8142,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   {
     // encode iteration count
 
-    char salt_iter[5];
+    char salt_iter[5] = { 0 };
 
     salt_iter[0] = int_to_itoa64 ((salt.salt_iter      ) & 0x3f);
     salt_iter[1] = int_to_itoa64 ((salt.salt_iter >>  6) & 0x3f);
@@ -8070,7 +8167,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     memcpy (tmp_buf, digest_buf, 8);
 
-    base64_encode (int_to_itoa64, tmp_buf, 8, ptr_plain);
+    base64_encode (int_to_itoa64, (const u8 *) tmp_buf, 8, (u8 *) ptr_plain);
 
     ptr_plain[11] = 0;
 
@@ -8112,7 +8209,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 12800)
   {
-    const uint8_t *ptr = (const uint8_t *) salt.salt_buf;
+    const u8 *ptr = (const u8 *) salt.salt_buf;
 
     snprintf (out_buf, len-1, "%s,%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x,%d,%08x%08x%08x%08x%08x%08x%08x%08x",
       SIGNATURE_MS_DRSR,
@@ -8182,6 +8279,36 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
       byte_swap_32 (digest_buf[1])
     );
   }
+  else if (hash_mode == 13100)
+  {
+    krb5tgs_t *krb5tgss = (krb5tgs_t *) data.esalts_buf;
+
+    krb5tgs_t *krb5tgs = &krb5tgss[salt_pos];
+
+    u8 *ptr_checksum  = (u8 *) krb5tgs->checksum;
+    u8 *ptr_edata2 = (u8 *) krb5tgs->edata2;
+
+    char data[256] = { 0 };
+
+    char *ptr_data = data;
+
+    for (uint i = 0; i < 16; i++, ptr_data += 2)
+      sprintf (ptr_data, "%02x", ptr_checksum[i]);
+
+    /* skip '$' */
+    ptr_data++;
+
+    for (uint i = 0; i < 32; i++, ptr_data += 2)
+      sprintf (ptr_data, "%02x", ptr_edata2[i]);
+
+    *ptr_data = 0;
+
+    snprintf (out_buf, len-1, "%s$%s$%s$%s",
+      SIGNATURE_KRB5TGS,
+      (char *) krb5tgs->account_info,
+      data,
+      data + 33);
+  }
   else
   {
     if (hash_type == HASH_TYPE_MD4)
@@ -8261,8 +8388,8 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
     }
     else if (hash_type == HASH_TYPE_BCRYPT)
     {
-      base64_encode (int_to_bf64, (char *) salt.salt_buf, 16, tmp_buf + 0);
-      base64_encode (int_to_bf64, (char *) digest_buf, 23, tmp_buf + 22);
+      base64_encode (int_to_bf64, (const u8 *) salt.salt_buf, 16, (u8 *) tmp_buf + 0);
+      base64_encode (int_to_bf64, (const u8 *) digest_buf,    23, (u8 *) tmp_buf + 22);
 
       tmp_buf[22 + 31] = 0; // base64_encode wants to pad
 
@@ -8381,14 +8508,14 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
       digest_buf[ 2] = byte_swap_32 (digest_buf[ 2]);
       digest_buf[ 3] = byte_swap_32 (digest_buf[ 3]);
 
-      char buf[16];
+      char buf[16] = { 0 };
 
       memcpy (buf + 0, salt.salt_buf, 5);
       memcpy (buf + 5, digest_buf, 9);
 
       buf[3] -= -4;
 
-      base64_encode (int_to_lotus64, buf, 14, tmp_buf);
+      base64_encode (int_to_lotus64, (const u8 *) buf, 14, (u8 *) tmp_buf);
 
       tmp_buf[18] = salt.salt_buf_pc[7];
       tmp_buf[19] = 0;
@@ -8397,9 +8524,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
     }
     else if (hash_type == HASH_TYPE_LOTUS8)
     {
-      char buf[52];
-
-      memset (buf, 0, sizeof (buf));
+      char buf[52] = { 0 };
 
       // salt
 
@@ -8420,7 +8545,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
       memcpy (buf + 28, digest_buf, 8);
 
-      base64_encode (int_to_lotus64, buf, 36, tmp_buf);
+      base64_encode (int_to_lotus64, (const u8 *) buf, 36, (u8 *) tmp_buf);
 
       tmp_buf[49] = 0;
 
@@ -8463,7 +8588,7 @@ void to_hccap_t (hccap_t *hccap, uint salt_pos, uint digest_pos)
 
   if (wpa->keyver != 1)
   {
-    uint eapol_tmp[64];
+    uint eapol_tmp[64] = { 0 };
 
     for (uint i = 0; i < 64; i++)
     {
@@ -8477,7 +8602,7 @@ 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];
+  uint pke_tmp[25] = { 0 };
 
   for (int i = 5; i < 25; i++)
   {
@@ -8499,7 +8624,7 @@ void to_hccap_t (hccap_t *hccap, uint salt_pos, uint digest_pos)
 
   if (wpa->keyver != 1)
   {
-    uint digest_tmp[4];
+    uint digest_tmp[4] = { 0 };
 
     digest_tmp[0] = byte_swap_32 (digest_ptr[0]);
     digest_tmp[1] = byte_swap_32 (digest_ptr[1]);
@@ -8607,11 +8732,11 @@ void myquit ()
   data.devices_status = STATUS_QUIT;
 }
 
-void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const unsigned char **kernel_sources)
+void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources)
 {
-  FILE *fp;
+  FILE *fp = fopen (kernel_file, "rb");
 
-  if ((fp = fopen (kernel_file, "rb")) != NULL)
+  if (fp != NULL)
   {
     struct stat st;
 
@@ -8619,9 +8744,9 @@ void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengt
 
     stat (kernel_file, &st);
 
-    unsigned char *buf = (unsigned char *) mymalloc (st.st_size + 1);
+    u8 *buf = (u8 *) mymalloc (st.st_size + 1);
 
-    size_t num_read = fread (buf, sizeof (unsigned char), st.st_size, fp);
+    size_t num_read = fread (buf, sizeof (u8), st.st_size, fp);
 
     if (num_read != (size_t) st.st_size)
     {
@@ -8651,14 +8776,18 @@ void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengt
   return;
 }
 
-void writeProgramBin (char *dst, unsigned char *binary, size_t binary_size)
+void writeProgramBin (char *dst, u8 *binary, size_t binary_size)
 {
-  FILE *fp = fopen (dst, "wb");
+  if (binary_size > 0)
+  {
+    FILE *fp = fopen (dst, "wb");
 
-  fwrite (binary, sizeof (unsigned char), binary_size, fp);
+    lock_file (fp);
+    fwrite (binary, sizeof (u8), binary_size, fp);
 
-  fflush (fp);
-  fclose (fp);
+    fflush (fp);
+    fclose (fp);
+  }
 }
 
 /**
@@ -8688,13 +8817,11 @@ restore_data_t *init_restore (int argc, char **argv)
 
       if (rd->pid)
       {
-        char pidbin[BUFSIZ];
+        char pidbin[BUFSIZ] = { 0 };
 
-        int pidbin_len;
+        int pidbin_len = -1;
 
         #ifdef _POSIX
-        memset (pidbin, 0, sizeof (pidbin));
-
         snprintf (pidbin, sizeof (pidbin) - 1, "/proc/%d/cmdline", rd->pid);
 
         FILE *fd = fopen (pidbin, "rb");
@@ -8726,11 +8853,9 @@ restore_data_t *init_restore (int argc, char **argv)
         #elif _WIN
         HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid);
 
-        char pidbin2[BUFSIZ];
-
-        int pidbin2_len;
+        char pidbin2[BUFSIZ] = { 0 };
 
-        memset (pidbin2, 0, sizeof (pidbin2));
+        int pidbin2_len = -1;
 
         pidbin_len = GetModuleFileName (NULL, pidbin, BUFSIZ);
         pidbin2_len = GetModuleFileNameEx (hProcess, NULL, pidbin2, BUFSIZ);
@@ -8804,7 +8929,7 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
 
   for (uint i = 0; i < rd->argc; i++)
   {
-    char buf[BUFSIZ];
+    char buf[BUFSIZ] = { 0 };
 
     if (fgets (buf, BUFSIZ - 1, fp) == NULL)
     {
@@ -8822,7 +8947,7 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
 
   fclose (fp);
 
-  char new_cwd[256];
+  char new_cwd[1024] = { 0 };
 
   char *nwd = getcwd (new_cwd, sizeof (new_cwd));
 
@@ -8843,7 +8968,6 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
     log_info ("WARNING: Found old restore file, updating path to %s...", new_cwd);
   }
 
-
   if (chdir (rd->cwd))
   {
     log_error ("ERROR: cannot chdir to %s: %s", rd->cwd, strerror (errno));
@@ -8852,15 +8976,17 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
   }
 }
 
-uint64_t get_lowest_words_done ()
+u64 get_lowest_words_done ()
 {
-  uint64_t words_cur = -1;
+  u64 words_cur = -1;
 
   for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
   {
     hc_device_param_t *device_param = &data.devices_param[device_id];
 
-    const uint64_t words_done = device_param->words_done;
+    if (device_param->skipped) continue;
+
+    const u64 words_done = device_param->words_done;
 
     if (words_done < words_cur) words_cur = words_done;
   }
@@ -8878,7 +9004,7 @@ uint64_t get_lowest_words_done ()
 
 void write_restore (const char *new_restore_file, restore_data_t *rd)
 {
-  uint64_t words_cur = get_lowest_words_done ();
+  u64 words_cur = get_lowest_words_done ();
 
   rd->words_cur = words_cur;
 
@@ -8906,428 +9032,329 @@ void write_restore (const char *new_restore_file, restore_data_t *rd)
     fputc ('\n', fp);
   }
 
-  fflush (fp);
+  fflush (fp);
+
+  fsync (fileno (fp));
+
+  fclose (fp);
+}
+
+void cycle_restore ()
+{
+  const char *eff_restore_file = data.eff_restore_file;
+  const char *new_restore_file = data.new_restore_file;
+
+  restore_data_t *rd = data.rd;
+
+  write_restore (new_restore_file, rd);
+
+  struct stat st;
+
+  memset (&st, 0, sizeof(st));
+
+  if (stat (eff_restore_file, &st) == 0)
+  {
+    if (unlink (eff_restore_file))
+    {
+      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));
+  }
+}
+
+void check_checkpoint ()
+{
+  // if (data.restore_disable == 1) break;  (this is already implied by previous checks)
+
+  u64 words_cur = get_lowest_words_done ();
+
+  if (words_cur != data.checkpoint_cur_words)
+  {
+    myabort ();
+  }
+}
+
+/**
+ * tuning db
+ */
+
+void tuning_db_destroy (tuning_db_t *tuning_db)
+{
+  int i;
+
+  for (i = 0; i < tuning_db->alias_cnt; i++)
+  {
+    tuning_db_alias_t *alias = &tuning_db->alias_buf[i];
+
+    myfree (alias->device_name);
+    myfree (alias->alias_name);
+  }
+
+  for (i = 0; i < tuning_db->entry_cnt; i++)
+  {
+    tuning_db_entry_t *entry = &tuning_db->entry_buf[i];
+
+    myfree (entry->device_name);
+  }
+
+  myfree (tuning_db->alias_buf);
+  myfree (tuning_db->entry_buf);
+
+  myfree (tuning_db);
+}
+
+tuning_db_t *tuning_db_alloc (FILE *fp)
+{
+  tuning_db_t *tuning_db = (tuning_db_t *) mymalloc (sizeof (tuning_db_t));
+
+  int num_lines = count_lines (fp);
+
+  // a bit over-allocated
+
+  tuning_db->alias_buf = (tuning_db_alias_t *) mycalloc (num_lines + 1, sizeof (tuning_db_alias_t));
+  tuning_db->alias_cnt = 0;
+
+  tuning_db->entry_buf = (tuning_db_entry_t *) mycalloc (num_lines + 1, sizeof (tuning_db_entry_t));
+  tuning_db->entry_cnt = 0;
+
+  return tuning_db;
+}
+
+tuning_db_t *tuning_db_init (const char *tuning_db_file)
+{
+  FILE *fp = fopen (tuning_db_file, "rb");
+
+  if (fp == NULL)
+  {
+    log_error ("%s: %s", tuning_db_file, strerror (errno));
+
+    exit (-1);
+  }
+
+  tuning_db_t *tuning_db = tuning_db_alloc (fp);
+
+  rewind (fp);
+
+  int line_num = 0;
+
+  while (!feof (fp))
+  {
+    char buf[BUFSIZ];
+
+    char *line_buf = fgets (buf, sizeof (buf) - 1, fp);
+
+    if (line_buf == NULL) break;
+
+    line_num++;
+
+    const int line_len = in_superchop (line_buf);
+
+    if (line_len == 0) continue;
+
+    if (line_buf[0] == '#') continue;
+
+    // start processing
+
+    char *token_ptr[7] = { NULL };
+
+    int token_cnt = 0;
+
+    char *next = strtok (line_buf, "\t ");
+
+    token_ptr[token_cnt] = next;
+
+    token_cnt++;
+
+    while ((next = strtok (NULL, "\t ")) != NULL)
+    {
+      token_ptr[token_cnt] = next;
+
+      token_cnt++;
+    }
+
+    if (token_cnt == 2)
+    {
+      char *device_name = token_ptr[0];
+      char *alias_name  = token_ptr[1];
+
+      tuning_db_alias_t *alias = &tuning_db->alias_buf[tuning_db->alias_cnt];
+
+      alias->device_name = mystrdup (device_name);
+      alias->alias_name  = mystrdup (alias_name);
+
+      tuning_db->alias_cnt++;
+    }
+    else if (token_cnt == 6)
+    {
+      if ((token_ptr[1][0] != '0') &&
+          (token_ptr[1][0] != '1') &&
+          (token_ptr[1][0] != '3') &&
+          (token_ptr[1][0] != '*'))
+      {
+        log_info ("WARNING: Tuning-db: Invalid attack_mode '%c' in Line '%u'", token_ptr[1][0], line_num);
+
+        continue;
+      }
+
+      if ((token_ptr[3][0] != '1') &&
+          (token_ptr[3][0] != '2') &&
+          (token_ptr[3][0] != '4') &&
+          (token_ptr[3][0] != '8') &&
+          (token_ptr[3][0] != 'N'))
+      {
+        log_info ("WARNING: Tuning-db: Invalid vector_width '%c' in Line '%u'", token_ptr[3][0], line_num);
+
+        continue;
+      }
+
+      char *device_name = token_ptr[0];
+
+      int attack_mode      = -1;
+      int hash_type        = -1;
+      int vector_width     = -1;
+      int kernel_accel     = -1;
+      int kernel_loops     = -1;
+
+      if (token_ptr[1][0] != '*') attack_mode      = atoi (token_ptr[1]);
+      if (token_ptr[2][0] != '*') hash_type        = atoi (token_ptr[2]);
+      if (token_ptr[3][0] != 'N') vector_width     = atoi (token_ptr[3]);
+
+      if (token_ptr[4][0] != 'A')
+      {
+        kernel_accel = atoi (token_ptr[4]);
+
+        if ((kernel_accel < 1) || (kernel_accel > 1024))
+        {
+          log_info ("WARNING: Tuning-db: Invalid kernel_accel '%d' in Line '%u'", kernel_accel, line_num);
+
+          continue;
+        }
+      }
+      else
+      {
+        kernel_accel = 0;
+      }
+
+      if (token_ptr[5][0] != 'A')
+      {
+        kernel_loops = atoi (token_ptr[5]);
+
+        if ((kernel_loops < 1) || (kernel_loops > 1024))
+        {
+          log_info ("WARNING: Tuning-db: Invalid kernel_loops '%d' in Line '%u'", kernel_loops, line_num);
+
+          continue;
+        }
+      }
+      else
+      {
+        kernel_loops = 0;
+      }
+
+      tuning_db_entry_t *entry = &tuning_db->entry_buf[tuning_db->entry_cnt];
+
+      entry->device_name  = mystrdup (device_name);
+      entry->attack_mode  = attack_mode;
+      entry->hash_type    = hash_type;
+      entry->vector_width = vector_width;
+      entry->kernel_accel = kernel_accel;
+      entry->kernel_loops = kernel_loops;
+
+      tuning_db->entry_cnt++;
+    }
+    else
+    {
+      log_info ("WARNING: Tuning-db: Invalid number of token in Line '%u'", line_num);
+
+      continue;
+    }
+  }
+
+  fclose (fp);
+
+  // todo: print loaded 'cnt' message
+
+  // sort the database
+
+  qsort (tuning_db->alias_buf, tuning_db->alias_cnt, sizeof (tuning_db_alias_t), sort_by_tuning_db_alias);
+  qsort (tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry);
+
+  return tuning_db;
+}
+
+tuning_db_entry_t *tuning_db_search (tuning_db_t *tuning_db, char *device_name, int attack_mode, int hash_type)
+{
+  static tuning_db_entry_t s;
+
+  // first we need to convert all spaces in the device_name to underscore
+
+  char *device_name_nospace = strdup (device_name);
+
+  int device_name_length = strlen (device_name_nospace);
+
+  int i;
+
+  for (i = 0; i < device_name_length; i++)
+  {
+    if (device_name_nospace[i] == ' ') device_name_nospace[i] = '_';
+  }
+
+  // find out if there's an alias configured
+
+  tuning_db_alias_t a;
+
+  a.device_name = device_name_nospace;
+
+  tuning_db_alias_t *alias = bsearch (&a, tuning_db->alias_buf, tuning_db->alias_cnt, sizeof (tuning_db_alias_t), sort_by_tuning_db_alias);
 
-  fsync (fileno (fp));
+  char *alias_name = (alias == NULL) ? NULL : alias->alias_name;
 
-  fclose (fp);
-}
+  // attack-mode 6 and 7 are attack-mode 1 basically
 
-void cycle_restore ()
-{
-  const char *eff_restore_file = data.eff_restore_file;
-  const char *new_restore_file = data.new_restore_file;
+  if (attack_mode == 6) attack_mode = 1;
+  if (attack_mode == 7) attack_mode = 1;
 
-  restore_data_t *rd = data.rd;
+  // bsearch is not ideal but fast enough
 
-  write_restore (new_restore_file, rd);
+  s.device_name = device_name_nospace;
+  s.attack_mode = attack_mode;
+  s.hash_type   = hash_type;
 
-  struct stat st;
+  tuning_db_entry_t *entry = NULL;
 
-  memset (&st, 0, sizeof(st));
+  // this will produce all 2^3 combinations required
 
-  if (stat (eff_restore_file, &st) == 0)
+  for (i = 0; i < 8; i++)
   {
-    if (unlink (eff_restore_file))
-    {
-      log_info ("WARN: unlink file '%s': %s", eff_restore_file, strerror (errno));
-    }
-  }
+    s.device_name = (i & 1) ? "*" : device_name_nospace;
+    s.attack_mode = (i & 2) ?  -1 : attack_mode;
+    s.hash_type   = (i & 4) ?  -1 : hash_type;
 
-  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));
-  }
-}
+    entry = bsearch (&s, tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry);
 
-void check_checkpoint ()
-{
-  // if (data.restore_disable == 1) break;  (this is already implied by previous checks)
+    if (entry != NULL) break;
 
-  uint64_t words_cur = get_lowest_words_done ();
+    // in non-wildcard mode also check the alias_name
 
-  if (words_cur != data.checkpoint_cur_words)
-  {
-    myabort ();
-  }
-}
+    if (((i & 1) == 0) && (alias_name != NULL))
+    {
+      s.device_name = alias_name;
 
-/**
- * adjustments
- */
+      entry = bsearch (&s, tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry);
 
-uint set_kernel_accel (uint hash_mode)
-{
-  switch (hash_mode)
-  {
-    case     0: return GET_ACCEL (0);
-    case    10: return GET_ACCEL (10);
-    case    11: return GET_ACCEL (11);
-    case    12: return GET_ACCEL (12);
-    case    20: return GET_ACCEL (20);
-    case    21: return GET_ACCEL (21);
-    case    22: return GET_ACCEL (22);
-    case    23: return GET_ACCEL (23);
-    case    30: return GET_ACCEL (30);
-    case    40: return GET_ACCEL (40);
-    case    50: return GET_ACCEL (50);
-    case    60: return GET_ACCEL (60);
-    case   100: return GET_ACCEL (100);
-    case   101: return GET_ACCEL (101);
-    case   110: return GET_ACCEL (110);
-    case   111: return GET_ACCEL (111);
-    case   112: return GET_ACCEL (112);
-    case   120: return GET_ACCEL (120);
-    case   121: return GET_ACCEL (121);
-    case   122: return GET_ACCEL (122);
-    case   124: return GET_ACCEL (124);
-    case   130: return GET_ACCEL (130);
-    case   131: return GET_ACCEL (131);
-    case   132: return GET_ACCEL (132);
-    case   133: return GET_ACCEL (133);
-    case   140: return GET_ACCEL (140);
-    case   141: return GET_ACCEL (141);
-    case   150: return GET_ACCEL (150);
-    case   160: return GET_ACCEL (160);
-    case   190: return GET_ACCEL (190);
-    case   200: return GET_ACCEL (200);
-    case   300: return GET_ACCEL (300);
-    case   400: return GET_ACCEL (400);
-    case   500: return GET_ACCEL (500);
-    case   501: return GET_ACCEL (501);
-    case   900: return GET_ACCEL (900);
-    case   910: return GET_ACCEL (910);
-    case  1000: return GET_ACCEL (1000);
-    case  1100: return GET_ACCEL (1100);
-    case  1400: return GET_ACCEL (1400);
-    case  1410: return GET_ACCEL (1410);
-    case  1420: return GET_ACCEL (1420);
-    case  1421: return GET_ACCEL (1421);
-    case  1430: return GET_ACCEL (1430);
-    case  1440: return GET_ACCEL (1440);
-    case  1441: return GET_ACCEL (1441);
-    case  1450: return GET_ACCEL (1450);
-    case  1460: return GET_ACCEL (1460);
-    case  1500: return GET_ACCEL (1500);
-    case  1600: return GET_ACCEL (1600);
-    case  1700: return GET_ACCEL (1700);
-    case  1710: return GET_ACCEL (1710);
-    case  1711: return GET_ACCEL (1711);
-    case  1720: return GET_ACCEL (1720);
-    case  1722: return GET_ACCEL (1722);
-    case  1730: return GET_ACCEL (1730);
-    case  1731: return GET_ACCEL (1731);
-    case  1740: return GET_ACCEL (1740);
-    case  1750: return GET_ACCEL (1750);
-    case  1760: return GET_ACCEL (1760);
-    case  1800: return GET_ACCEL (1800);
-    case  2100: return GET_ACCEL (2100);
-    case  2400: return GET_ACCEL (2400);
-    case  2410: return GET_ACCEL (2410);
-    case  2500: return GET_ACCEL (2500);
-    case  2600: return GET_ACCEL (2600);
-    case  2611: return GET_ACCEL (2611);
-    case  2612: return GET_ACCEL (2612);
-    case  2711: return GET_ACCEL (2711);
-    case  2811: return GET_ACCEL (2811);
-    case  3000: return GET_ACCEL (3000);
-    case  3100: return GET_ACCEL (3100);
-    case  3200: return GET_ACCEL (3200);
-    case  3710: return GET_ACCEL (3710);
-    case  3711: return GET_ACCEL (3711);
-    case  3800: return GET_ACCEL (3800);
-    case  4300: return GET_ACCEL (4300);
-    case  4400: return GET_ACCEL (4400);
-    case  4500: return GET_ACCEL (4500);
-    case  4700: return GET_ACCEL (4700);
-    case  4800: return GET_ACCEL (4800);
-    case  4900: return GET_ACCEL (4900);
-    case  5000: return GET_ACCEL (5000);
-    case  5100: return GET_ACCEL (5100);
-    case  5200: return GET_ACCEL (5200);
-    case  5300: return GET_ACCEL (5300);
-    case  5400: return GET_ACCEL (5400);
-    case  5500: return GET_ACCEL (5500);
-    case  5600: return GET_ACCEL (5600);
-    case  5700: return GET_ACCEL (5700);
-    case  5800: return GET_ACCEL (5800);
-    case  6000: return GET_ACCEL (6000);
-    case  6100: return GET_ACCEL (6100);
-    case  6211: return GET_ACCEL (6211);
-    case  6212: return GET_ACCEL (6212);
-    case  6213: return GET_ACCEL (6213);
-    case  6221: return GET_ACCEL (6221);
-    case  6222: return GET_ACCEL (6222);
-    case  6223: return GET_ACCEL (6223);
-    case  6231: return GET_ACCEL (6231);
-    case  6232: return GET_ACCEL (6232);
-    case  6233: return GET_ACCEL (6233);
-    case  6241: return GET_ACCEL (6241);
-    case  6242: return GET_ACCEL (6242);
-    case  6243: return GET_ACCEL (6243);
-    case  6300: return GET_ACCEL (6300);
-    case  6400: return GET_ACCEL (6400);
-    case  6500: return GET_ACCEL (6500);
-    case  6600: return GET_ACCEL (6600);
-    case  6700: return GET_ACCEL (6700);
-    case  6800: return GET_ACCEL (6800);
-    case  6900: return GET_ACCEL (6900);
-    case  7100: return GET_ACCEL (7100);
-    case  7200: return GET_ACCEL (7200);
-    case  7300: return GET_ACCEL (7300);
-    case  7400: return GET_ACCEL (7400);
-    case  7500: return GET_ACCEL (7500);
-    case  7600: return GET_ACCEL (7600);
-    case  7700: return GET_ACCEL (7700);
-    case  7800: return GET_ACCEL (7800);
-    case  7900: return GET_ACCEL (7900);
-    case  8000: return GET_ACCEL (8000);
-    case  8100: return GET_ACCEL (8100);
-    case  8200: return GET_ACCEL (8200);
-    case  8300: return GET_ACCEL (8300);
-    case  8400: return GET_ACCEL (8400);
-    case  8500: return GET_ACCEL (8500);
-    case  8600: return GET_ACCEL (8600);
-    case  8700: return GET_ACCEL (8700);
-    case  8800: return GET_ACCEL (8800);
-    case  8900: return GET_ACCEL (8900);
-    case  9000: return GET_ACCEL (9000);
-    case  9100: return GET_ACCEL (9100);
-    case  9200: return GET_ACCEL (9200);
-    case  9300: return GET_ACCEL (9300);
-    case  9400: return GET_ACCEL (9400);
-    case  9500: return GET_ACCEL (9500);
-    case  9600: return GET_ACCEL (9600);
-    case  9700: return GET_ACCEL (9700);
-    case  9710: return GET_ACCEL (9710);
-    case  9720: return GET_ACCEL (9720);
-    case  9800: return GET_ACCEL (9800);
-    case  9810: return GET_ACCEL (9810);
-    case  9820: return GET_ACCEL (9820);
-    case  9900: return GET_ACCEL (9900);
-    case 10000: return GET_ACCEL (10000);
-    case 10100: return GET_ACCEL (10100);
-    case 10200: return GET_ACCEL (10200);
-    case 10300: return GET_ACCEL (10300);
-    case 10400: return GET_ACCEL (10400);
-    case 10410: return GET_ACCEL (10410);
-    case 10420: return GET_ACCEL (10420);
-    case 10500: return GET_ACCEL (10500);
-    case 10600: return GET_ACCEL (10600);
-    case 10700: return GET_ACCEL (10700);
-    case 10800: return GET_ACCEL (10800);
-    case 10900: return GET_ACCEL (10900);
-    case 11000: return GET_ACCEL (11000);
-    case 11100: return GET_ACCEL (11100);
-    case 11200: return GET_ACCEL (11200);
-    case 11300: return GET_ACCEL (11300);
-    case 11400: return GET_ACCEL (11400);
-    case 11500: return GET_ACCEL (11500);
-    case 11600: return GET_ACCEL (11600);
-    case 11700: return GET_ACCEL (11700);
-    case 11800: return GET_ACCEL (11800);
-    case 11900: return GET_ACCEL (11900);
-    case 12000: return GET_ACCEL (12000);
-    case 12100: return GET_ACCEL (12100);
-    case 12200: return GET_ACCEL (12200);
-    case 12300: return GET_ACCEL (12300);
-    case 12400: return GET_ACCEL (12400);
-    case 12500: return GET_ACCEL (12500);
-    case 12600: return GET_ACCEL (12600);
-    case 12700: return GET_ACCEL (12700);
-    case 12800: return GET_ACCEL (12800);
-    case 12900: return GET_ACCEL (12900);
-    case 13000: return GET_ACCEL (13000);
+      if (entry != NULL) break;
+    }
   }
 
-  return 0;
-}
+  // free converted device_name
 
-uint set_kernel_loops (uint hash_mode)
-{
-  switch (hash_mode)
-  {
-    case     0: return GET_LOOPS (0);
-    case    10: return GET_LOOPS (10);
-    case    11: return GET_LOOPS (11);
-    case    12: return GET_LOOPS (12);
-    case    20: return GET_LOOPS (20);
-    case    21: return GET_LOOPS (21);
-    case    22: return GET_LOOPS (22);
-    case    23: return GET_LOOPS (23);
-    case    30: return GET_LOOPS (30);
-    case    40: return GET_LOOPS (40);
-    case    50: return GET_LOOPS (50);
-    case    60: return GET_LOOPS (60);
-    case   100: return GET_LOOPS (100);
-    case   101: return GET_LOOPS (101);
-    case   110: return GET_LOOPS (110);
-    case   111: return GET_LOOPS (111);
-    case   112: return GET_LOOPS (112);
-    case   120: return GET_LOOPS (120);
-    case   121: return GET_LOOPS (121);
-    case   122: return GET_LOOPS (122);
-    case   124: return GET_LOOPS (124);
-    case   130: return GET_LOOPS (130);
-    case   131: return GET_LOOPS (131);
-    case   132: return GET_LOOPS (132);
-    case   133: return GET_LOOPS (133);
-    case   140: return GET_LOOPS (140);
-    case   141: return GET_LOOPS (141);
-    case   150: return GET_LOOPS (150);
-    case   160: return GET_LOOPS (160);
-    case   190: return GET_LOOPS (190);
-    case   200: return GET_LOOPS (200);
-    case   300: return GET_LOOPS (300);
-    case   400: return GET_LOOPS (400);
-    case   500: return GET_LOOPS (500);
-    case   501: return GET_LOOPS (501);
-    case   900: return GET_LOOPS (900);
-    case   910: return GET_LOOPS (910);
-    case  1000: return GET_LOOPS (1000);
-    case  1100: return GET_LOOPS (1100);
-    case  1400: return GET_LOOPS (1400);
-    case  1410: return GET_LOOPS (1410);
-    case  1420: return GET_LOOPS (1420);
-    case  1421: return GET_LOOPS (1421);
-    case  1430: return GET_LOOPS (1430);
-    case  1440: return GET_LOOPS (1440);
-    case  1441: return GET_LOOPS (1441);
-    case  1450: return GET_LOOPS (1450);
-    case  1460: return GET_LOOPS (1460);
-    case  1500: return GET_LOOPS (1500);
-    case  1600: return GET_LOOPS (1600);
-    case  1700: return GET_LOOPS (1700);
-    case  1710: return GET_LOOPS (1710);
-    case  1711: return GET_LOOPS (1711);
-    case  1720: return GET_LOOPS (1720);
-    case  1722: return GET_LOOPS (1722);
-    case  1730: return GET_LOOPS (1730);
-    case  1731: return GET_LOOPS (1731);
-    case  1740: return GET_LOOPS (1740);
-    case  1750: return GET_LOOPS (1750);
-    case  1760: return GET_LOOPS (1760);
-    case  1800: return GET_LOOPS (1800);
-    case  2100: return GET_LOOPS (2100);
-    case  2400: return GET_LOOPS (2400);
-    case  2410: return GET_LOOPS (2410);
-    case  2500: return GET_LOOPS (2500);
-    case  2600: return GET_LOOPS (2600);
-    case  2611: return GET_LOOPS (2611);
-    case  2612: return GET_LOOPS (2612);
-    case  2711: return GET_LOOPS (2711);
-    case  2811: return GET_LOOPS (2811);
-    case  3000: return GET_LOOPS (3000);
-    case  3100: return GET_LOOPS (3100);
-    case  3200: return GET_LOOPS (3200);
-    case  3710: return GET_LOOPS (3710);
-    case  3711: return GET_LOOPS (3711);
-    case  3800: return GET_LOOPS (3800);
-    case  4300: return GET_LOOPS (4300);
-    case  4400: return GET_LOOPS (4400);
-    case  4500: return GET_LOOPS (4500);
-    case  4700: return GET_LOOPS (4700);
-    case  4800: return GET_LOOPS (4800);
-    case  4900: return GET_LOOPS (4900);
-    case  5000: return GET_LOOPS (5000);
-    case  5100: return GET_LOOPS (5100);
-    case  5200: return GET_LOOPS (5200);
-    case  5300: return GET_LOOPS (5300);
-    case  5400: return GET_LOOPS (5400);
-    case  5500: return GET_LOOPS (5500);
-    case  5600: return GET_LOOPS (5600);
-    case  5700: return GET_LOOPS (5700);
-    case  5800: return GET_LOOPS (5800);
-    case  6000: return GET_LOOPS (6000);
-    case  6100: return GET_LOOPS (6100);
-    case  6211: return GET_LOOPS (6211);
-    case  6212: return GET_LOOPS (6212);
-    case  6213: return GET_LOOPS (6213);
-    case  6221: return GET_LOOPS (6221);
-    case  6222: return GET_LOOPS (6222);
-    case  6223: return GET_LOOPS (6223);
-    case  6231: return GET_LOOPS (6231);
-    case  6232: return GET_LOOPS (6232);
-    case  6233: return GET_LOOPS (6233);
-    case  6241: return GET_LOOPS (6241);
-    case  6242: return GET_LOOPS (6242);
-    case  6243: return GET_LOOPS (6243);
-    case  6300: return GET_LOOPS (6300);
-    case  6400: return GET_LOOPS (6400);
-    case  6500: return GET_LOOPS (6500);
-    case  6600: return GET_LOOPS (6600);
-    case  6700: return GET_LOOPS (6700);
-    case  6800: return GET_LOOPS (6800);
-    case  6900: return GET_LOOPS (6900);
-    case  7100: return GET_LOOPS (7100);
-    case  7200: return GET_LOOPS (7200);
-    case  7300: return GET_LOOPS (7300);
-    case  7400: return GET_LOOPS (7400);
-    case  7500: return GET_LOOPS (7500);
-    case  7600: return GET_LOOPS (7600);
-    case  7700: return GET_LOOPS (7700);
-    case  7800: return GET_LOOPS (7800);
-    case  7900: return GET_LOOPS (7900);
-    case  8000: return GET_LOOPS (8000);
-    case  8100: return GET_LOOPS (8100);
-    case  8200: return GET_LOOPS (8200);
-    case  8300: return GET_LOOPS (8300);
-    case  8400: return GET_LOOPS (8400);
-    case  8500: return GET_LOOPS (8500);
-    case  8600: return GET_LOOPS (8600);
-    case  8700: return GET_LOOPS (8700);
-    case  8800: return GET_LOOPS (8800);
-    case  8900: return GET_LOOPS (8900);
-    case  9000: return GET_LOOPS (9000);
-    case  9100: return GET_LOOPS (9100);
-    case  9200: return GET_LOOPS (9200);
-    case  9300: return GET_LOOPS (9300);
-    case  9400: return GET_LOOPS (9400);
-    case  9500: return GET_LOOPS (9500);
-    case  9600: return GET_LOOPS (9600);
-    case  9700: return GET_LOOPS (9700);
-    case  9710: return GET_LOOPS (9710);
-    case  9720: return GET_LOOPS (9720);
-    case  9800: return GET_LOOPS (9800);
-    case  9810: return GET_LOOPS (9810);
-    case  9820: return GET_LOOPS (9820);
-    case  9900: return GET_LOOPS (9900);
-    case 10000: return GET_LOOPS (10000);
-    case 10100: return GET_LOOPS (10100);
-    case 10200: return GET_LOOPS (10200);
-    case 10300: return GET_LOOPS (10300);
-    case 10400: return GET_LOOPS (10400);
-    case 10410: return GET_LOOPS (10410);
-    case 10420: return GET_LOOPS (10420);
-    case 10500: return GET_LOOPS (10500);
-    case 10600: return GET_LOOPS (10600);
-    case 10700: return GET_LOOPS (10700);
-    case 10800: return GET_LOOPS (10800);
-    case 10900: return GET_LOOPS (10900);
-    case 11000: return GET_LOOPS (11000);
-    case 11100: return GET_LOOPS (11100);
-    case 11200: return GET_LOOPS (11200);
-    case 11300: return GET_LOOPS (11300);
-    case 11400: return GET_LOOPS (11400);
-    case 11500: return GET_LOOPS (11500);
-    case 11600: return GET_LOOPS (11600);
-    case 11700: return GET_LOOPS (11700);
-    case 11800: return GET_LOOPS (11800);
-    case 11900: return GET_LOOPS (11900);
-    case 12000: return GET_LOOPS (12000);
-    case 12100: return GET_LOOPS (12100);
-    case 12200: return GET_LOOPS (12200);
-    case 12300: return GET_LOOPS (12300);
-    case 12400: return GET_LOOPS (12400);
-    case 12500: return GET_LOOPS (12500);
-    case 12600: return GET_LOOPS (12600);
-    case 12700: return GET_LOOPS (12700);
-    case 12800: return GET_LOOPS (12800);
-    case 12900: return GET_LOOPS (12900);
-    case 13000: return GET_LOOPS (13000);
-  }
+  myfree (device_name_nospace);
 
-  return 0;
+  return entry;
 }
 
 /**
@@ -9336,26 +9363,25 @@ uint set_kernel_loops (uint hash_mode)
 
 uint parse_and_store_salt (char *out, char *in, uint salt_len)
 {
-  char tmp[256];
+  u8 tmp[256] = { 0 };
 
-  if (salt_len > sizeof(tmp))
+  if (salt_len > sizeof (tmp))
   {
     return UINT_MAX;
   }
 
-  memset (tmp, 0, sizeof (tmp));
   memcpy (tmp, in, salt_len);
 
   if (data.opts_type & OPTS_TYPE_ST_HEX)
   {
     if ((salt_len % 2) == 0)
     {
-      uint new_salt_len = salt_len / 2;
+      u32 new_salt_len = salt_len / 2;
 
       for (uint i = 0, j = 0; i < new_salt_len; i += 1, j += 2)
       {
-        char p0 = tmp[j + 0];
-        char p1 = tmp[j + 1];
+        u8 p0 = tmp[j + 0];
+        u8 p1 = tmp[j + 1];
 
         tmp[i]  = hex_convert (p1) << 0;
         tmp[i] |= hex_convert (p0) << 4;
@@ -9370,7 +9396,7 @@ uint parse_and_store_salt (char *out, char *in, uint salt_len)
   }
   else if (data.opts_type & OPTS_TYPE_ST_BASE64)
   {
-    salt_len = base64_decode (base64_to_int, in, salt_len, tmp);
+    salt_len = base64_decode (base64_to_int, (const u8 *) in, salt_len, (u8 *) tmp);
   }
 
   memset (tmp + salt_len, 0, sizeof (tmp) - salt_len);
@@ -9379,7 +9405,7 @@ uint parse_and_store_salt (char *out, char *in, uint salt_len)
   {
     if (salt_len < 20)
     {
-      uint *tmp_uint = (uint *) tmp;
+      u32 *tmp_uint = (u32 *) tmp;
 
       tmp_uint[9] = ((tmp_uint[4] >> 8) & 0x00FF0000) | ((tmp_uint[4] >> 16) & 0x000000FF);
       tmp_uint[8] = ((tmp_uint[4] << 8) & 0x00FF0000) | ((tmp_uint[4] >>  0) & 0x000000FF);
@@ -9410,7 +9436,7 @@ uint parse_and_store_salt (char *out, char *in, uint salt_len)
     uppercase (tmp, salt_len);
   }
 
-  uint len = salt_len;
+  u32 len = salt_len;
 
   if (data.opts_type & OPTS_TYPE_ST_ADD80)
   {
@@ -9424,13 +9450,13 @@ uint parse_and_store_salt (char *out, char *in, uint salt_len)
 
   if (data.opts_type & OPTS_TYPE_ST_GENERATE_LE)
   {
-    uint *tmp_uint = (uint *) tmp;
+    u32 *tmp_uint = (uint *) tmp;
 
-    uint max = len / 4;
+    u32 max = len / 4;
 
     if (len % 4) max++;
 
-    for (uint i = 0; i < max; i++)
+    for (u32 i = 0; i < max; i++)
     {
       tmp_uint[i] = byte_swap_32 (tmp_uint[i]);
     }
@@ -9456,7 +9482,7 @@ int bcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((memcmp (SIGNATURE_BCRYPT1, input_buf, 4)) && (memcmp (SIGNATURE_BCRYPT2, input_buf, 4)) && (memcmp (SIGNATURE_BCRYPT3, input_buf, 4))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -9476,11 +9502,9 @@ int bcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len;
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  base64_decode (bf64_to_int, salt_pos, 22, tmp_buf);
+  base64_decode (bf64_to_int, (const u8 *) salt_pos, 22, tmp_buf);
 
   char *salt_buf_ptr = (char *) salt->salt_buf;
 
@@ -9495,7 +9519,7 @@ int bcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   memset (tmp_buf, 0, sizeof (tmp_buf));
 
-  base64_decode (bf64_to_int, hash_pos, 31, tmp_buf);
+  base64_decode (bf64_to_int, (const u8 *) hash_pos, 31, tmp_buf);
 
   memcpy (digest, tmp_buf, 24);
 
@@ -9515,13 +9539,11 @@ int cisco4_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_5700) || (input_len > DISPLAY_LEN_MAX_5700)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
-
-  char tmp_buf[100];
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  base64_decode (itoa64_to_int, input_buf, 43, tmp_buf);
+  base64_decode (itoa64_to_int, (const u8 *) input_buf, 43, tmp_buf);
 
   memcpy (digest, tmp_buf, 32);
 
@@ -9550,10 +9572,10 @@ int lm_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_3000) || (input_len > DISPLAY_LEN_MAX_3000)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
+  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
 
   digest[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -9574,17 +9596,17 @@ 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);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
   char *hash_pos = input_buf + 8;
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
+  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;
@@ -9609,20 +9631,20 @@ int osx512_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_1722) || (input_len > DISPLAY_LEN_MAX_1722)) return (PARSER_GLOBAL_LENGTH);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
   char *hash_pos = input_buf + 8;
 
-  digest[0] = hex_to_uint64_t (&hash_pos[  0]);
-  digest[1] = hex_to_uint64_t (&hash_pos[ 16]);
-  digest[2] = hex_to_uint64_t (&hash_pos[ 32]);
-  digest[3] = hex_to_uint64_t (&hash_pos[ 48]);
-  digest[4] = hex_to_uint64_t (&hash_pos[ 64]);
-  digest[5] = hex_to_uint64_t (&hash_pos[ 80]);
-  digest[6] = hex_to_uint64_t (&hash_pos[ 96]);
-  digest[7] = hex_to_uint64_t (&hash_pos[112]);
+  digest[0] = hex_to_u64 ((const u8 *) &hash_pos[  0]);
+  digest[1] = hex_to_u64 ((const u8 *) &hash_pos[ 16]);
+  digest[2] = hex_to_u64 ((const u8 *) &hash_pos[ 32]);
+  digest[3] = hex_to_u64 ((const u8 *) &hash_pos[ 48]);
+  digest[4] = hex_to_u64 ((const u8 *) &hash_pos[ 64]);
+  digest[5] = hex_to_u64 ((const u8 *) &hash_pos[ 80]);
+  digest[6] = hex_to_u64 ((const u8 *) &hash_pos[ 96]);
+  digest[7] = hex_to_u64 ((const u8 *) &hash_pos[112]);
 
   digest[0] -= SHA512M_A;
   digest[1] -= SHA512M_B;
@@ -9657,14 +9679,14 @@ int osc_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_21) || (input_len > DISPLAY_LEN_MAX_21)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -9706,7 +9728,7 @@ int netscreen_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // unscramble
 
-  char clean_input_buf[32];
+  char clean_input_buf[32] = { 0 };
 
   char sig[6] = { 'n', 'r', 'c', 's', 't', 'n' };
   int  pos[6] = {   0,   6,  12,  17,  23,  29 };
@@ -9729,11 +9751,11 @@ int netscreen_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // base64 decode
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  char a, b, c, d, e, f;
+  u32 a, b, c, d, e, f;
 
   a = base64_to_int (clean_input_buf[ 0] & 0x7f);
   b = base64_to_int (clean_input_buf[ 1] & 0x7f);
@@ -9743,7 +9765,7 @@ int netscreen_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   f = base64_to_int (clean_input_buf[ 5] & 0x7f);
 
   digest[0] = (((a << 12) | (b << 6) | (c)) << 16)
-                        | (((d << 12) | (e << 6) | (f)) <<  0);
+            | (((d << 12) | (e << 6) | (f)) <<  0);
 
   a = base64_to_int (clean_input_buf[ 6] & 0x7f);
   b = base64_to_int (clean_input_buf[ 7] & 0x7f);
@@ -9753,7 +9775,7 @@ int netscreen_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   f = base64_to_int (clean_input_buf[11] & 0x7f);
 
   digest[1] = (((a << 12) | (b << 6) | (c)) << 16)
-                        | (((d << 12) | (e << 6) | (f)) <<  0);
+            | (((d << 12) | (e << 6) | (f)) <<  0);
 
   a = base64_to_int (clean_input_buf[12] & 0x7f);
   b = base64_to_int (clean_input_buf[13] & 0x7f);
@@ -9763,7 +9785,7 @@ int netscreen_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   f = base64_to_int (clean_input_buf[17] & 0x7f);
 
   digest[2] = (((a << 12) | (b << 6) | (c)) << 16)
-                        | (((d << 12) | (e << 6) | (f)) <<  0);
+            | (((d << 12) | (e << 6) | (f)) <<  0);
 
   a = base64_to_int (clean_input_buf[18] & 0x7f);
   b = base64_to_int (clean_input_buf[19] & 0x7f);
@@ -9773,7 +9795,7 @@ int netscreen_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   f = base64_to_int (clean_input_buf[23] & 0x7f);
 
   digest[3] = (((a << 12) | (b << 6) | (c)) << 16)
-                        | (((d << 12) | (e << 6) | (f)) <<  0);
+            | (((d << 12) | (e << 6) | (f)) <<  0);
 
   digest[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -9818,15 +9840,15 @@ int smf_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_121) || (input_len > DISPLAY_LEN_MAX_121)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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] -= SHA1M_A;
   digest[1] -= SHA1M_B;
@@ -9891,12 +9913,12 @@ int dcc2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   uint salt_len = digest_pos - salt_pos - 1;
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&digest_pos[ 0]);
-  digest[1] = hex_to_uint (&digest_pos[ 8]);
-  digest[2] = hex_to_uint (&digest_pos[16]);
-  digest[3] = hex_to_uint (&digest_pos[24]);
+  digest[0] = hex_to_u32 ((const u8 *) &digest_pos[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &digest_pos[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &digest_pos[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &digest_pos[24]);
 
   char *salt_buf_ptr = (char *) salt->salt_buf;
 
@@ -9911,7 +9933,7 @@ int dcc2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
 int wpa_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -9928,7 +9950,7 @@ int wpa_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   /*
     http://www.one-net.eu/jsw/j_sec/m_ptype.html
     The phrase "Pairwise key expansion"
-    Access Point Address (Referred to as Authenticator Address AA)
+    Access Point Address (referred to as Authenticator Address AA)
     Supplicant Address (referred to as Supplicant Address SA)
     Access Point Nonce (referred to as Authenticator Anonce)
     Wireless Device Nonce (referred to as Supplicant Nonce Snonce)
@@ -10021,7 +10043,7 @@ int wpa_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
 int psafe2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -10041,17 +10063,10 @@ int psafe2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     exit (-1);
   }
 
-  typedef struct
-  {
-    uint32_t random[2];
-    uint32_t hash[5];
-    uint32_t salt[5];   // unused, but makes better valid check
-    uint32_t iv[2];     // unused, but makes better valid check
-
-  } psafe2_hdr;
-
   psafe2_hdr buf;
 
+  memset (&buf, 0, sizeof (psafe2_hdr));
+
   int n = fread (&buf, sizeof (psafe2_hdr), 1, fp);
 
   fclose (fp);
@@ -10075,7 +10090,7 @@ int psafe2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
 int psafe3_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -10147,7 +10162,7 @@ int phpass_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((memcmp (SIGNATURE_PHPASS1, input_buf, 3)) && (memcmp (SIGNATURE_PHPASS2, input_buf, 3))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -10180,7 +10195,7 @@ int md5crypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if (memcmp (SIGNATURE_MD5CRYPT, input_buf, 3)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -10239,7 +10254,7 @@ int md5apr1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if (memcmp (SIGNATURE_MD5APR1, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -10296,7 +10311,7 @@ int episerver_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_EPISERVER, input_buf, 14)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -10318,9 +10333,9 @@ int episerver_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len;
 
-  char tmp_buf[100]; memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  base64_decode (base64_to_int, hash_pos, 27, tmp_buf);
+  base64_decode (base64_to_int, (const u8 *) hash_pos, 27, tmp_buf);
 
   memcpy (digest, tmp_buf, 20);
 
@@ -10347,7 +10362,7 @@ int descrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (c12 & 3) return (PARSER_HASH_VALUE);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -10360,11 +10375,9 @@ int descrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = 2;
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  base64_decode (itoa64_to_int, input_buf + 2, 11, tmp_buf);
+  base64_decode (itoa64_to_int, (const u8 *) input_buf + 2, 11, tmp_buf);
 
   memcpy (digest, tmp_buf, 8);
 
@@ -10382,12 +10395,12 @@ int md4_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_900) || (input_len > DISPLAY_LEN_MAX_900)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -10413,14 +10426,14 @@ int md4s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_910) || (input_len > DISPLAY_LEN_MAX_910)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -10453,12 +10466,12 @@ int md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_0) || (input_len > DISPLAY_LEN_MAX_0)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -10477,10 +10490,10 @@ int md5half_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_5100) || (input_len > DISPLAY_LEN_MAX_5100)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[0]);
-  digest[1] = hex_to_uint (&input_buf[8]);
+  digest[0] = hex_to_u32 ((const u8 *) &input_buf[0]);
+  digest[1] = hex_to_u32 ((const u8 *) &input_buf[8]);
   digest[2] = 0;
   digest[3] = 0;
 
@@ -10501,14 +10514,14 @@ int md5s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_10) || (input_len > DISPLAY_LEN_MAX_10)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -10541,7 +10554,7 @@ int md5pix_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_2400) || (input_len > DISPLAY_LEN_MAX_2400)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   digest[0] = itoa64_to_int (input_buf[ 0]) <<  0
             | itoa64_to_int (input_buf[ 1]) <<  6
@@ -10584,7 +10597,7 @@ int md5asa_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_2410) || (input_len > DISPLAY_LEN_MAX_2410)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -10632,7 +10645,7 @@ int md5asa_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   return (PARSER_OK);
 }
 
-void transform_netntlmv1_key (const uint8_t *nthash, uint8_t *key)
+void transform_netntlmv1_key (const u8 *nthash, u8 *key)
 {
   key[0] =                    (nthash[0] >> 0);
   key[1] = (nthash[0] << 7) | (nthash[1] >> 1);
@@ -10657,7 +10670,7 @@ int netntlmv1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_5500) || (input_len > DISPLAY_LEN_MAX_5500)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -10789,10 +10802,10 @@ int netntlmv1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len;
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -10801,10 +10814,10 @@ int netntlmv1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   /* special case, last 8 byte do not need to be checked since they are brute-forced next */
 
-  uint digest_tmp[2];
+  uint digest_tmp[2] = { 0 };
 
-  digest_tmp[0] = hex_to_uint (&hash_pos[32]);
-  digest_tmp[1] = hex_to_uint (&hash_pos[40]);
+  digest_tmp[0] = hex_to_u32 ((const u8 *) &hash_pos[32]);
+  digest_tmp[1] = hex_to_u32 ((const u8 *) &hash_pos[40]);
 
   digest_tmp[0] = byte_swap_32 (digest_tmp[0]);
   digest_tmp[1] = byte_swap_32 (digest_tmp[1]);
@@ -10815,26 +10828,16 @@ int netntlmv1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   {
     if ((netntlm->chall_buf[2] == 0) && (netntlm->chall_buf[3] == 0) && (netntlm->chall_buf[4] == 0) && (netntlm->chall_buf[5] == 0))
     {
-      uint w[16];
+      uint w[16] = { 0 };
 
       w[ 0] = netntlm->chall_buf[6];
       w[ 1] = netntlm->chall_buf[7];
       w[ 2] = netntlm->chall_buf[0];
       w[ 3] = netntlm->chall_buf[1];
       w[ 4] = 0x80;
-      w[ 5] = 0;
-      w[ 6] = 0;
-      w[ 7] = 0;
-      w[ 8] = 0;
-      w[ 9] = 0;
-      w[10] = 0;
-      w[11] = 0;
-      w[12] = 0;
-      w[13] = 0;
       w[14] = 16 * 8;
-      w[15] = 0;
 
-      uint dgst[4];
+      uint dgst[4] = { 0 };
 
       dgst[0] = MAGIC_A;
       dgst[1] = MAGIC_B;
@@ -10855,10 +10858,10 @@ int netntlmv1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     uint key_md4[2] = { i, 0 };
     uint key_des[2] = { 0, 0 };
 
-    transform_netntlmv1_key ((uint8_t *) key_md4, (uint8_t *) key_des);
+    transform_netntlmv1_key ((u8 *) key_md4, (u8 *) key_des);
 
-    uint Kc[16];
-    uint Kd[16];
+    uint Kc[16] = { 0 };
+    uint Kd[16] = { 0 };
 
     _des_keysetup (key_des, Kc, Kd, c_skb);
 
@@ -10881,20 +10884,20 @@ int netntlmv1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   /* precompute netntlmv1 exploit stop */
 
-  uint32_t tt;
+  u32 tt;
 
   IP (digest[0], digest[1], tt);
   IP (digest[2], digest[3], tt);
 
-  digest[0] = ROTATE_RIGHT (digest[0], 29);
-  digest[1] = ROTATE_RIGHT (digest[1], 29);
-  digest[2] = ROTATE_RIGHT (digest[2], 29);
-  digest[3] = ROTATE_RIGHT (digest[3], 29);
+  digest[0] = rotr32 (digest[0], 29);
+  digest[1] = rotr32 (digest[1], 29);
+  digest[2] = rotr32 (digest[2], 29);
+  digest[3] = rotr32 (digest[3], 29);
 
   IP (salt->salt_buf[0], salt->salt_buf[1], tt);
 
-  salt->salt_buf[0] = ROTATE_LEFT (salt->salt_buf[0], 3);
-  salt->salt_buf[1] = ROTATE_LEFT (salt->salt_buf[1], 3);
+  salt->salt_buf[0] = rotl32 (salt->salt_buf[0], 3);
+  salt->salt_buf[1] = rotl32 (salt->salt_buf[1], 3);
 
   return (PARSER_OK);
 }
@@ -10903,7 +10906,7 @@ int netntlmv2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_5600) || (input_len > DISPLAY_LEN_MAX_5600)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -11033,10 +11036,10 @@ int netntlmv2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * handle hash itself
    */
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -11088,14 +11091,14 @@ int joomla_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_11) || (input_len > DISPLAY_LEN_MAX_11)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -11135,14 +11138,14 @@ int postgresql_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_12) || (input_len > DISPLAY_LEN_MAX_12)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -11175,14 +11178,14 @@ int md5md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_2600) || (input_len > DISPLAY_LEN_MAX_2600)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -11222,14 +11225,14 @@ int vb3_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_2611) || (input_len > DISPLAY_LEN_MAX_2611)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -11269,14 +11272,14 @@ int vb30_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_2711) || (input_len > DISPLAY_LEN_MAX_2711)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -11311,14 +11314,14 @@ int dcc_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_1100) || (input_len > DISPLAY_LEN_MAX_1100)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -11358,14 +11361,14 @@ int ipb2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_2811) || (input_len > DISPLAY_LEN_MAX_2811)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -11378,9 +11381,7 @@ int ipb2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *salt_buf = input_buf + 32 + 1;
 
-  uint salt_pc_block[16];
-
-  memset (salt_pc_block, 0, sizeof (salt_pc_block));
+  uint salt_pc_block[16] = { 0 };
 
   char *salt_pc_block_ptr = (char *) salt_pc_block;
 
@@ -11392,12 +11393,7 @@ int ipb2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt_pc_block[14] = salt_len * 8;
 
-  uint salt_pc_digest[4];
-
-  salt_pc_digest[0] = MAGIC_A;
-  salt_pc_digest[1] = MAGIC_B;
-  salt_pc_digest[2] = MAGIC_C;
-  salt_pc_digest[3] = MAGIC_D;
+  uint salt_pc_digest[4] = { MAGIC_A, MAGIC_B, MAGIC_C, MAGIC_D };
 
   md5_64 (salt_pc_block, salt_pc_digest);
 
@@ -11406,11 +11402,11 @@ int ipb2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   salt_pc_digest[2] = byte_swap_32 (salt_pc_digest[2]);
   salt_pc_digest[3] = byte_swap_32 (salt_pc_digest[3]);
 
-  char *salt_buf_ptr = (char *) salt->salt_buf;
+  u8 *salt_buf_ptr = (u8 *) salt->salt_buf;
 
   memcpy (salt_buf_ptr, salt_buf, salt_len);
 
-  char *salt_buf_pc_ptr = (char *) salt->salt_buf_pc;
+  u8 *salt_buf_pc_ptr = (u8 *) salt->salt_buf_pc;
 
   bin_to_hex_lower (salt_pc_digest[0], salt_buf_pc_ptr +  0);
   bin_to_hex_lower (salt_pc_digest[1], salt_buf_pc_ptr +  8);
@@ -11426,13 +11422,13 @@ int sha1_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);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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] -= SHA1M_A;
   digest[1] -= SHA1M_B;
@@ -11447,13 +11443,13 @@ 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);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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);
 }
@@ -11469,15 +11465,15 @@ int sha1s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_110) || (input_len > DISPLAY_LEN_MAX_110)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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] -= SHA1M_A;
   digest[1] -= SHA1M_B;
@@ -11508,13 +11504,11 @@ int sha1b64_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SHA1B64, input_buf, 5)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
-
-  char tmp_buf[100];
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  base64_decode (base64_to_int, input_buf + 5, input_len - 5, tmp_buf);
+  base64_decode (base64_to_int, (const u8 *) input_buf + 5, input_len - 5, tmp_buf);
 
   memcpy (digest, tmp_buf, 20);
 
@@ -11539,15 +11533,13 @@ int sha1b64s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SSHA1B64_lower, input_buf, 6) && memcmp (SIGNATURE_SSHA1B64_upper, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  int tmp_len = base64_decode (base64_to_int, input_buf + 6, input_len - 6, tmp_buf);
+  int tmp_len = base64_decode (base64_to_int, (const u8 *) input_buf + 6, input_len - 6, tmp_buf);
 
   memcpy (digest, tmp_buf, 20);
 
@@ -11583,7 +11575,7 @@ int mssql2000_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_MSSQL, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -11601,11 +11593,11 @@ int mssql2000_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *hash_pos = input_buf + 6 + 8 + 40;
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
+  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;
@@ -11622,7 +11614,7 @@ int mssql2005_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_MSSQL, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -11640,11 +11632,11 @@ int mssql2005_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *hash_pos = input_buf + 6 + 8;
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
+  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;
@@ -11661,7 +11653,7 @@ int mssql2012_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_MSSQL2012, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -11679,14 +11671,14 @@ int mssql2012_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *hash_pos = input_buf + 6 + 8;
 
-  digest[0] = hex_to_uint64_t (&hash_pos[  0]);
-  digest[1] = hex_to_uint64_t (&hash_pos[ 16]);
-  digest[2] = hex_to_uint64_t (&hash_pos[ 32]);
-  digest[3] = hex_to_uint64_t (&hash_pos[ 48]);
-  digest[4] = hex_to_uint64_t (&hash_pos[ 64]);
-  digest[5] = hex_to_uint64_t (&hash_pos[ 80]);
-  digest[6] = hex_to_uint64_t (&hash_pos[ 96]);
-  digest[7] = hex_to_uint64_t (&hash_pos[112]);
+  digest[0] = hex_to_u64 ((const u8 *) &hash_pos[  0]);
+  digest[1] = hex_to_u64 ((const u8 *) &hash_pos[ 16]);
+  digest[2] = hex_to_u64 ((const u8 *) &hash_pos[ 32]);
+  digest[3] = hex_to_u64 ((const u8 *) &hash_pos[ 48]);
+  digest[4] = hex_to_u64 ((const u8 *) &hash_pos[ 64]);
+  digest[5] = hex_to_u64 ((const u8 *) &hash_pos[ 80]);
+  digest[6] = hex_to_u64 ((const u8 *) &hash_pos[ 96]);
+  digest[7] = hex_to_u64 ((const u8 *) &hash_pos[112]);
 
   digest[0] -= SHA512M_A;
   digest[1] -= SHA512M_B;
@@ -11711,12 +11703,12 @@ int oracleh_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_3100) || (input_len > DISPLAY_LEN_MAX_3100)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
+  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
   digest[2] = 0;
   digest[3] = 0;
 
@@ -11744,15 +11736,15 @@ int oracles_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_112) || (input_len > DISPLAY_LEN_MAX_112)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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] -= SHA1M_A;
   digest[1] -= SHA1M_B;
@@ -11781,35 +11773,35 @@ int oraclet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_12300) || (input_len > DISPLAY_LEN_MAX_12300)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
   char *hash_pos = input_buf;
 
-  digest[ 0] = hex_to_uint (&hash_pos[  0]);
-  digest[ 1] = hex_to_uint (&hash_pos[  8]);
-  digest[ 2] = hex_to_uint (&hash_pos[ 16]);
-  digest[ 3] = hex_to_uint (&hash_pos[ 24]);
-  digest[ 4] = hex_to_uint (&hash_pos[ 32]);
-  digest[ 5] = hex_to_uint (&hash_pos[ 40]);
-  digest[ 6] = hex_to_uint (&hash_pos[ 48]);
-  digest[ 7] = hex_to_uint (&hash_pos[ 56]);
-  digest[ 8] = hex_to_uint (&hash_pos[ 64]);
-  digest[ 9] = hex_to_uint (&hash_pos[ 72]);
-  digest[10] = hex_to_uint (&hash_pos[ 80]);
-  digest[11] = hex_to_uint (&hash_pos[ 88]);
-  digest[12] = hex_to_uint (&hash_pos[ 96]);
-  digest[13] = hex_to_uint (&hash_pos[104]);
-  digest[14] = hex_to_uint (&hash_pos[112]);
-  digest[15] = hex_to_uint (&hash_pos[120]);
+  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[ 5] = hex_to_u32 ((const u8 *) &hash_pos[ 40]);
+  digest[ 6] = hex_to_u32 ((const u8 *) &hash_pos[ 48]);
+  digest[ 7] = hex_to_u32 ((const u8 *) &hash_pos[ 56]);
+  digest[ 8] = hex_to_u32 ((const u8 *) &hash_pos[ 64]);
+  digest[ 9] = hex_to_u32 ((const u8 *) &hash_pos[ 72]);
+  digest[10] = hex_to_u32 ((const u8 *) &hash_pos[ 80]);
+  digest[11] = hex_to_u32 ((const u8 *) &hash_pos[ 88]);
+  digest[12] = hex_to_u32 ((const u8 *) &hash_pos[ 96]);
+  digest[13] = hex_to_u32 ((const u8 *) &hash_pos[104]);
+  digest[14] = hex_to_u32 ((const u8 *) &hash_pos[112]);
+  digest[15] = hex_to_u32 ((const u8 *) &hash_pos[120]);
 
   char *salt_pos = input_buf + 128;
 
-  salt->salt_buf[0] = hex_to_uint (&salt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&salt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&salt_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&salt_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &salt_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &salt_pos[24]);
 
   salt->salt_iter = ROUNDS_ORACLET - 1;
   salt->salt_len  = 16;
@@ -11821,16 +11813,16 @@ int sha256_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_1400) || (input_len > DISPLAY_LEN_MAX_1400)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
-  digest[5] = hex_to_uint (&input_buf[40]);
-  digest[6] = hex_to_uint (&input_buf[48]);
-  digest[7] = hex_to_uint (&input_buf[56]);
+  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]);
 
   digest[0] -= SHA256M_A;
   digest[1] -= SHA256M_B;
@@ -11855,18 +11847,18 @@ int sha256s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_1410) || (input_len > DISPLAY_LEN_MAX_1410)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
-  digest[5] = hex_to_uint (&input_buf[40]);
-  digest[6] = hex_to_uint (&input_buf[48]);
-  digest[7] = hex_to_uint (&input_buf[56]);
+  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]);
 
   digest[0] -= SHA256M_A;
   digest[1] -= SHA256M_B;
@@ -11898,14 +11890,14 @@ int sha384_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_10800) || (input_len > DISPLAY_LEN_MAX_10800)) return (PARSER_GLOBAL_LENGTH);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint64_t (&input_buf[  0]);
-  digest[1] = hex_to_uint64_t (&input_buf[ 16]);
-  digest[2] = hex_to_uint64_t (&input_buf[ 32]);
-  digest[3] = hex_to_uint64_t (&input_buf[ 48]);
-  digest[4] = hex_to_uint64_t (&input_buf[ 64]);
-  digest[5] = hex_to_uint64_t (&input_buf[ 80]);
+  digest[0] = hex_to_u64 ((const u8 *) &input_buf[  0]);
+  digest[1] = hex_to_u64 ((const u8 *) &input_buf[ 16]);
+  digest[2] = hex_to_u64 ((const u8 *) &input_buf[ 32]);
+  digest[3] = hex_to_u64 ((const u8 *) &input_buf[ 48]);
+  digest[4] = hex_to_u64 ((const u8 *) &input_buf[ 64]);
+  digest[5] = hex_to_u64 ((const u8 *) &input_buf[ 80]);
   digest[6] = 0;
   digest[7] = 0;
 
@@ -11925,16 +11917,16 @@ int sha512_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_1700) || (input_len > DISPLAY_LEN_MAX_1700)) return (PARSER_GLOBAL_LENGTH);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint64_t (&input_buf[  0]);
-  digest[1] = hex_to_uint64_t (&input_buf[ 16]);
-  digest[2] = hex_to_uint64_t (&input_buf[ 32]);
-  digest[3] = hex_to_uint64_t (&input_buf[ 48]);
-  digest[4] = hex_to_uint64_t (&input_buf[ 64]);
-  digest[5] = hex_to_uint64_t (&input_buf[ 80]);
-  digest[6] = hex_to_uint64_t (&input_buf[ 96]);
-  digest[7] = hex_to_uint64_t (&input_buf[112]);
+  digest[0] = hex_to_u64 ((const u8 *) &input_buf[  0]);
+  digest[1] = hex_to_u64 ((const u8 *) &input_buf[ 16]);
+  digest[2] = hex_to_u64 ((const u8 *) &input_buf[ 32]);
+  digest[3] = hex_to_u64 ((const u8 *) &input_buf[ 48]);
+  digest[4] = hex_to_u64 ((const u8 *) &input_buf[ 64]);
+  digest[5] = hex_to_u64 ((const u8 *) &input_buf[ 80]);
+  digest[6] = hex_to_u64 ((const u8 *) &input_buf[ 96]);
+  digest[7] = hex_to_u64 ((const u8 *) &input_buf[112]);
 
   digest[0] -= SHA512M_A;
   digest[1] -= SHA512M_B;
@@ -11959,18 +11951,18 @@ int sha512s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_1710) || (input_len > DISPLAY_LEN_MAX_1710)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint64_t (&input_buf[  0]);
-  digest[1] = hex_to_uint64_t (&input_buf[ 16]);
-  digest[2] = hex_to_uint64_t (&input_buf[ 32]);
-  digest[3] = hex_to_uint64_t (&input_buf[ 48]);
-  digest[4] = hex_to_uint64_t (&input_buf[ 64]);
-  digest[5] = hex_to_uint64_t (&input_buf[ 80]);
-  digest[6] = hex_to_uint64_t (&input_buf[ 96]);
-  digest[7] = hex_to_uint64_t (&input_buf[112]);
+  digest[0] = hex_to_u64 ((const u8 *) &input_buf[  0]);
+  digest[1] = hex_to_u64 ((const u8 *) &input_buf[ 16]);
+  digest[2] = hex_to_u64 ((const u8 *) &input_buf[ 32]);
+  digest[3] = hex_to_u64 ((const u8 *) &input_buf[ 48]);
+  digest[4] = hex_to_u64 ((const u8 *) &input_buf[ 64]);
+  digest[5] = hex_to_u64 ((const u8 *) &input_buf[ 80]);
+  digest[6] = hex_to_u64 ((const u8 *) &input_buf[ 96]);
+  digest[7] = hex_to_u64 ((const u8 *) &input_buf[112]);
 
   digest[0] -= SHA512M_A;
   digest[1] -= SHA512M_B;
@@ -12002,7 +11994,7 @@ int sha512crypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if (memcmp (SIGNATURE_SHA512CRYPT, input_buf, 3)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12059,7 +12051,7 @@ int keccak_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (input_len % 16) return (PARSER_GLOBAL_LENGTH);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12067,7 +12059,7 @@ int keccak_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   for (uint i = 0; i < keccak_mdlen / 8; i++)
   {
-    digest[i] = hex_to_uint64_t (&input_buf[i * 16]);
+    digest[i] = hex_to_u64 ((const u8 *) &input_buf[i * 16]);
 
     digest[i] = byte_swap_64 (digest[i]);
   }
@@ -12081,7 +12073,7 @@ int ikepsk_md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_5300) || (input_len > DISPLAY_LEN_MAX_5300)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12093,7 +12085,7 @@ int ikepsk_md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *in_off[9];
 
-  size_t in_len[9];
+  size_t in_len[9] = { 0 };
 
   in_off[0] = strtok (input_buf, ":");
 
@@ -12110,16 +12102,14 @@ int ikepsk_md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     in_len[i] = strlen (in_off[i]);
   }
 
-  char *ptr;
-
-  ptr = (char *) ikepsk->msg_buf;
+  char *ptr = (char *) ikepsk->msg_buf;
 
-  for (i = 0; i < in_len[0]; i += 2) *ptr++ = hex_to_char (in_off[0] + i);
-  for (i = 0; i < in_len[1]; i += 2) *ptr++ = hex_to_char (in_off[1] + i);
-  for (i = 0; i < in_len[2]; i += 2) *ptr++ = hex_to_char (in_off[2] + i);
-  for (i = 0; i < in_len[3]; i += 2) *ptr++ = hex_to_char (in_off[3] + i);
-  for (i = 0; i < in_len[4]; i += 2) *ptr++ = hex_to_char (in_off[4] + i);
-  for (i = 0; i < in_len[5]; i += 2) *ptr++ = hex_to_char (in_off[5] + i);
+  for (i = 0; i < in_len[0]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[0] + i);
+  for (i = 0; i < in_len[1]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[1] + i);
+  for (i = 0; i < in_len[2]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[2] + i);
+  for (i = 0; i < in_len[3]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[3] + i);
+  for (i = 0; i < in_len[4]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[4] + i);
+  for (i = 0; i < in_len[5]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[5] + i);
 
   *ptr = 0x80;
 
@@ -12127,8 +12117,8 @@ int ikepsk_md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   ptr = (char *) ikepsk->nr_buf;
 
-  for (i = 0; i < in_len[6]; i += 2) *ptr++ = hex_to_char (in_off[6] + i);
-  for (i = 0; i < in_len[7]; i += 2) *ptr++ = hex_to_char (in_off[7] + i);
+  for (i = 0; i < in_len[6]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[6] + i);
+  for (i = 0; i < in_len[7]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[7] + i);
 
   *ptr = 0x80;
 
@@ -12140,10 +12130,10 @@ int ikepsk_md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   ptr = in_off[8];
 
-  digest[0] = hex_to_uint (&ptr[ 0]);
-  digest[1] = hex_to_uint (&ptr[ 8]);
-  digest[2] = hex_to_uint (&ptr[16]);
-  digest[3] = hex_to_uint (&ptr[24]);
+  digest[0] = hex_to_u32 ((const u8 *) &ptr[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &ptr[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &ptr[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &ptr[24]);
 
   digest[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -12168,7 +12158,7 @@ int ikepsk_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_5400) || (input_len > DISPLAY_LEN_MAX_5400)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12180,7 +12170,7 @@ int ikepsk_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *in_off[9];
 
-  size_t in_len[9];
+  size_t in_len[9] = { 0 };
 
   in_off[0] = strtok (input_buf, ":");
 
@@ -12197,16 +12187,14 @@ int ikepsk_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     in_len[i] = strlen (in_off[i]);
   }
 
-  char *ptr;
+  char *ptr = (char *) ikepsk->msg_buf;
 
-  ptr = (char *) ikepsk->msg_buf;
-
-  for (i = 0; i < in_len[0]; i += 2) *ptr++ = hex_to_char (in_off[0] + i);
-  for (i = 0; i < in_len[1]; i += 2) *ptr++ = hex_to_char (in_off[1] + i);
-  for (i = 0; i < in_len[2]; i += 2) *ptr++ = hex_to_char (in_off[2] + i);
-  for (i = 0; i < in_len[3]; i += 2) *ptr++ = hex_to_char (in_off[3] + i);
-  for (i = 0; i < in_len[4]; i += 2) *ptr++ = hex_to_char (in_off[4] + i);
-  for (i = 0; i < in_len[5]; i += 2) *ptr++ = hex_to_char (in_off[5] + i);
+  for (i = 0; i < in_len[0]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[0] + i);
+  for (i = 0; i < in_len[1]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[1] + i);
+  for (i = 0; i < in_len[2]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[2] + i);
+  for (i = 0; i < in_len[3]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[3] + i);
+  for (i = 0; i < in_len[4]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[4] + i);
+  for (i = 0; i < in_len[5]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[5] + i);
 
   *ptr = 0x80;
 
@@ -12214,8 +12202,8 @@ int ikepsk_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   ptr = (char *) ikepsk->nr_buf;
 
-  for (i = 0; i < in_len[6]; i += 2) *ptr++ = hex_to_char (in_off[6] + i);
-  for (i = 0; i < in_len[7]; i += 2) *ptr++ = hex_to_char (in_off[7] + i);
+  for (i = 0; i < in_len[6]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[6] + i);
+  for (i = 0; i < in_len[7]; i += 2) *ptr++ = hex_to_u8 ((const u8 *) in_off[7] + i);
 
   *ptr = 0x80;
 
@@ -12227,11 +12215,11 @@ int ikepsk_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   ptr = in_off[8];
 
-  digest[0] = hex_to_uint (&ptr[ 0]);
-  digest[1] = hex_to_uint (&ptr[ 8]);
-  digest[2] = hex_to_uint (&ptr[16]);
-  digest[3] = hex_to_uint (&ptr[24]);
-  digest[4] = hex_to_uint (&ptr[32]);
+  digest[0] = hex_to_u32 ((const u8 *) &ptr[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &ptr[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &ptr[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &ptr[24]);
+  digest[4] = hex_to_u32 ((const u8 *) &ptr[32]);
 
   salt->salt_len = 32;
 
@@ -12251,13 +12239,13 @@ int ripemd160_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_6000) || (input_len > DISPLAY_LEN_MAX_6000)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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]);
@@ -12272,24 +12260,24 @@ int whirlpool_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_6100) || (input_len > DISPLAY_LEN_MAX_6100)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
-
-  digest[ 0] = hex_to_uint (&input_buf[  0]);
-  digest[ 1] = hex_to_uint (&input_buf[  8]);
-  digest[ 2] = hex_to_uint (&input_buf[ 16]);
-  digest[ 3] = hex_to_uint (&input_buf[ 24]);
-  digest[ 4] = hex_to_uint (&input_buf[ 32]);
-  digest[ 5] = hex_to_uint (&input_buf[ 40]);
-  digest[ 6] = hex_to_uint (&input_buf[ 48]);
-  digest[ 7] = hex_to_uint (&input_buf[ 56]);
-  digest[ 8] = hex_to_uint (&input_buf[ 64]);
-  digest[ 9] = hex_to_uint (&input_buf[ 72]);
-  digest[10] = hex_to_uint (&input_buf[ 80]);
-  digest[11] = hex_to_uint (&input_buf[ 88]);
-  digest[12] = hex_to_uint (&input_buf[ 96]);
-  digest[13] = hex_to_uint (&input_buf[104]);
-  digest[14] = hex_to_uint (&input_buf[112]);
-  digest[15] = hex_to_uint (&input_buf[120]);
+  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]);
+  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]);
+  digest[ 8] = hex_to_u32 ((const u8 *) &input_buf[ 64]);
+  digest[ 9] = hex_to_u32 ((const u8 *) &input_buf[ 72]);
+  digest[10] = hex_to_u32 ((const u8 *) &input_buf[ 80]);
+  digest[11] = hex_to_u32 ((const u8 *) &input_buf[ 88]);
+  digest[12] = hex_to_u32 ((const u8 *) &input_buf[ 96]);
+  digest[13] = hex_to_u32 ((const u8 *) &input_buf[104]);
+  digest[14] = hex_to_u32 ((const u8 *) &input_buf[112]);
+  digest[15] = hex_to_u32 ((const u8 *) &input_buf[120]);
 
   return (PARSER_OK);
 }
@@ -12298,15 +12286,15 @@ int androidpin_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_5800) || (input_len > DISPLAY_LEN_MAX_5800)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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]);
 
   if (input_buf[40] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
 
@@ -12329,7 +12317,7 @@ int androidpin_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
 int truecrypt_parse_hash_1k (char *input_buf, uint input_len, hash_t *hash_buf)
 {
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12351,7 +12339,7 @@ int truecrypt_parse_hash_1k (char *input_buf, uint input_len, hash_t *hash_buf)
     exit (-1);
   }
 
-  char buf[512];
+  char buf[512] = { 0 };
 
   int n = fread (buf, 1, sizeof (buf), fp);
 
@@ -12376,7 +12364,7 @@ int truecrypt_parse_hash_1k (char *input_buf, uint input_len, hash_t *hash_buf)
 
 int truecrypt_parse_hash_2k (char *input_buf, uint input_len, hash_t *hash_buf)
 {
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12398,7 +12386,7 @@ int truecrypt_parse_hash_2k (char *input_buf, uint input_len, hash_t *hash_buf)
     exit (-1);
   }
 
-  char buf[512];
+  char buf[512] = { 0 };
 
   int n = fread (buf, 1, sizeof (buf), fp);
 
@@ -12427,7 +12415,7 @@ int md5aix_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_MD5AIX, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12460,7 +12448,7 @@ int sha1aix_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SHA1AIX, input_buf, 7)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12509,7 +12497,7 @@ int sha256aix_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SHA256AIX, input_buf, 9)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12561,7 +12549,7 @@ int sha512aix_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SHA512AIX, input_buf, 9)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12611,7 +12599,7 @@ int agilekey_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_6600) || (input_len > DISPLAY_LEN_MAX_6600)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12727,7 +12715,7 @@ int lastpass_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_6800) || (input_len > DISPLAY_LEN_MAX_6800)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12765,10 +12753,10 @@ int lastpass_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_iter = atoi (iterations_pos) - 1;
 
-  digest[0] = hex_to_uint (&hashbuf_pos[ 0]);
-  digest[1] = hex_to_uint (&hashbuf_pos[ 8]);
-  digest[2] = hex_to_uint (&hashbuf_pos[16]);
-  digest[3] = hex_to_uint (&hashbuf_pos[24]);
+  digest[0] = hex_to_u32 ((const u8 *) &hashbuf_pos[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &hashbuf_pos[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &hashbuf_pos[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &hashbuf_pos[24]);
 
   return (PARSER_OK);
 }
@@ -12777,16 +12765,16 @@ int gost_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_6900) || (input_len > DISPLAY_LEN_MAX_6900)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
-  digest[5] = hex_to_uint (&input_buf[40]);
-  digest[6] = hex_to_uint (&input_buf[48]);
-  digest[7] = hex_to_uint (&input_buf[56]);
+  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]);
 
   digest[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -12804,7 +12792,7 @@ int sha256crypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if (memcmp (SIGNATURE_SHA256CRYPT, input_buf, 3)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12863,7 +12851,7 @@ int sha512osx_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SHA512OSX, input_buf, 4)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12885,14 +12873,14 @@ int sha512osx_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   hash_pos++;
 
-  digest[0] = hex_to_uint64_t (&hash_pos[  0]);
-  digest[1] = hex_to_uint64_t (&hash_pos[ 16]);
-  digest[2] = hex_to_uint64_t (&hash_pos[ 32]);
-  digest[3] = hex_to_uint64_t (&hash_pos[ 48]);
-  digest[4] = hex_to_uint64_t (&hash_pos[ 64]);
-  digest[5] = hex_to_uint64_t (&hash_pos[ 80]);
-  digest[6] = hex_to_uint64_t (&hash_pos[ 96]);
-  digest[7] = hex_to_uint64_t (&hash_pos[112]);
+  digest[0] = hex_to_u64 ((const u8 *) &hash_pos[  0]);
+  digest[1] = hex_to_u64 ((const u8 *) &hash_pos[ 16]);
+  digest[2] = hex_to_u64 ((const u8 *) &hash_pos[ 32]);
+  digest[3] = hex_to_u64 ((const u8 *) &hash_pos[ 48]);
+  digest[4] = hex_to_u64 ((const u8 *) &hash_pos[ 64]);
+  digest[5] = hex_to_u64 ((const u8 *) &hash_pos[ 80]);
+  digest[6] = hex_to_u64 ((const u8 *) &hash_pos[ 96]);
+  digest[7] = hex_to_u64 ((const u8 *) &hash_pos[112]);
 
   uint salt_len = hash_pos - salt_pos - 1;
 
@@ -12900,14 +12888,14 @@ int sha512osx_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len / 2;
 
-  pbkdf2_sha512->salt_buf[0] = hex_to_uint (&salt_pos[ 0]);
-  pbkdf2_sha512->salt_buf[1] = hex_to_uint (&salt_pos[ 8]);
-  pbkdf2_sha512->salt_buf[2] = hex_to_uint (&salt_pos[16]);
-  pbkdf2_sha512->salt_buf[3] = hex_to_uint (&salt_pos[24]);
-  pbkdf2_sha512->salt_buf[4] = hex_to_uint (&salt_pos[32]);
-  pbkdf2_sha512->salt_buf[5] = hex_to_uint (&salt_pos[40]);
-  pbkdf2_sha512->salt_buf[6] = hex_to_uint (&salt_pos[48]);
-  pbkdf2_sha512->salt_buf[7] = hex_to_uint (&salt_pos[56]);
+  pbkdf2_sha512->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_pos[ 0]);
+  pbkdf2_sha512->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_pos[ 8]);
+  pbkdf2_sha512->salt_buf[2] = hex_to_u32 ((const u8 *) &salt_pos[16]);
+  pbkdf2_sha512->salt_buf[3] = hex_to_u32 ((const u8 *) &salt_pos[24]);
+  pbkdf2_sha512->salt_buf[4] = hex_to_u32 ((const u8 *) &salt_pos[32]);
+  pbkdf2_sha512->salt_buf[5] = hex_to_u32 ((const u8 *) &salt_pos[40]);
+  pbkdf2_sha512->salt_buf[6] = hex_to_u32 ((const u8 *) &salt_pos[48]);
+  pbkdf2_sha512->salt_buf[7] = hex_to_u32 ((const u8 *) &salt_pos[56]);
 
   pbkdf2_sha512->salt_buf[0] = byte_swap_32 (pbkdf2_sha512->salt_buf[0]);
   pbkdf2_sha512->salt_buf[1] = byte_swap_32 (pbkdf2_sha512->salt_buf[1]);
@@ -12933,7 +12921,7 @@ int episerver4_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_EPISERVER4, input_buf, 14)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -12955,9 +12943,9 @@ int episerver4_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len;
 
-  char tmp_buf[100]; memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  base64_decode (base64_to_int, hash_pos, 43, tmp_buf);
+  base64_decode (base64_to_int, (const u8 *) hash_pos, 43, tmp_buf);
 
   memcpy (digest, tmp_buf, 32);
 
@@ -12990,7 +12978,7 @@ int sha512grub_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SHA512GRUB, input_buf, 19)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13012,14 +13000,14 @@ int sha512grub_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   hash_pos++;
 
-  digest[0] = hex_to_uint64_t (&hash_pos[  0]);
-  digest[1] = hex_to_uint64_t (&hash_pos[ 16]);
-  digest[2] = hex_to_uint64_t (&hash_pos[ 32]);
-  digest[3] = hex_to_uint64_t (&hash_pos[ 48]);
-  digest[4] = hex_to_uint64_t (&hash_pos[ 64]);
-  digest[5] = hex_to_uint64_t (&hash_pos[ 80]);
-  digest[6] = hex_to_uint64_t (&hash_pos[ 96]);
-  digest[7] = hex_to_uint64_t (&hash_pos[112]);
+  digest[0] = hex_to_u64 ((const u8 *) &hash_pos[  0]);
+  digest[1] = hex_to_u64 ((const u8 *) &hash_pos[ 16]);
+  digest[2] = hex_to_u64 ((const u8 *) &hash_pos[ 32]);
+  digest[3] = hex_to_u64 ((const u8 *) &hash_pos[ 48]);
+  digest[4] = hex_to_u64 ((const u8 *) &hash_pos[ 64]);
+  digest[5] = hex_to_u64 ((const u8 *) &hash_pos[ 80]);
+  digest[6] = hex_to_u64 ((const u8 *) &hash_pos[ 96]);
+  digest[7] = hex_to_u64 ((const u8 *) &hash_pos[112]);
 
   uint salt_len = hash_pos - salt_pos - 1;
 
@@ -13031,7 +13019,7 @@ int sha512grub_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   for (i = 0; i < salt_len; i++)
   {
-    salt_buf_ptr[i] = hex_to_char (&salt_pos[i * 2]);
+    salt_buf_ptr[i] = hex_to_u8 ((const u8 *) &salt_pos[i * 2]);
   }
 
   salt_buf_ptr[salt_len + 3] = 0x01;
@@ -13052,15 +13040,13 @@ int sha512b64s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SHA512B64S, input_buf, 9)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  char tmp_buf[120];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[120] = { 0 };
 
-  int tmp_len = base64_decode (base64_to_int, input_buf + 9, input_len - 9, tmp_buf);
+  int tmp_len = base64_decode (base64_to_int, (const u8 *) input_buf + 9, input_len - 9, tmp_buf);
 
   memcpy (digest, tmp_buf, 64);
 
@@ -13107,14 +13093,14 @@ int hmacmd5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_50) || (input_len > DISPLAY_LEN_MAX_50)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -13149,15 +13135,15 @@ int hmacsha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_150) || (input_len > DISPLAY_LEN_MAX_150)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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]);
 
   if (input_buf[40] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
 
@@ -13187,18 +13173,18 @@ int hmacsha256_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_1450) || (input_len > DISPLAY_LEN_MAX_1450)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
-  digest[5] = hex_to_uint (&input_buf[40]);
-  digest[6] = hex_to_uint (&input_buf[48]);
-  digest[7] = hex_to_uint (&input_buf[56]);
+  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);
 
@@ -13228,18 +13214,18 @@ int hmacsha512_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     if ((input_len < DISPLAY_LEN_MIN_1750) || (input_len > DISPLAY_LEN_MAX_1750)) return (PARSER_GLOBAL_LENGTH);
   }
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint64_t (&input_buf[  0]);
-  digest[1] = hex_to_uint64_t (&input_buf[ 16]);
-  digest[2] = hex_to_uint64_t (&input_buf[ 32]);
-  digest[3] = hex_to_uint64_t (&input_buf[ 48]);
-  digest[4] = hex_to_uint64_t (&input_buf[ 64]);
-  digest[5] = hex_to_uint64_t (&input_buf[ 80]);
-  digest[6] = hex_to_uint64_t (&input_buf[ 96]);
-  digest[7] = hex_to_uint64_t (&input_buf[112]);
+  digest[0] = hex_to_u64 ((const u8 *) &input_buf[  0]);
+  digest[1] = hex_to_u64 ((const u8 *) &input_buf[ 16]);
+  digest[2] = hex_to_u64 ((const u8 *) &input_buf[ 32]);
+  digest[3] = hex_to_u64 ((const u8 *) &input_buf[ 48]);
+  digest[4] = hex_to_u64 ((const u8 *) &input_buf[ 64]);
+  digest[5] = hex_to_u64 ((const u8 *) &input_buf[ 80]);
+  digest[6] = hex_to_u64 ((const u8 *) &input_buf[ 96]);
+  digest[7] = hex_to_u64 ((const u8 *) &input_buf[112]);
 
   if (input_buf[128] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
 
@@ -13264,7 +13250,7 @@ int krb5pa_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_KRB5PA, input_buf, 10)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13368,7 +13354,7 @@ int sapb_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_7700) || (input_len > DISPLAY_LEN_MAX_7700)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13423,8 +13409,8 @@ int sapb_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len;
 
-  digest[0] = hex_to_uint (&hash_pos[0]);
-  digest[1] = hex_to_uint (&hash_pos[8]);
+  digest[0] = hex_to_u32 ((const u8 *) &hash_pos[0]);
+  digest[1] = hex_to_u32 ((const u8 *) &hash_pos[8]);
   digest[2] = 0;
   digest[3] = 0;
 
@@ -13438,7 +13424,7 @@ int sapg_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_7800) || (input_len > DISPLAY_LEN_MAX_7800)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13497,11 +13483,11 @@ int sapg_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len;
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
+  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]);
 
   return (PARSER_OK);
 }
@@ -13512,7 +13498,7 @@ int drupal7_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_DRUPAL7, input_buf, 3)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13564,7 +13550,7 @@ int sybasease_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SYBASEASE, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13582,14 +13568,14 @@ int sybasease_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *hash_pos = input_buf + 6 + 16;
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
-  digest[5] = hex_to_uint (&hash_pos[40]);
-  digest[6] = hex_to_uint (&hash_pos[48]);
-  digest[7] = hex_to_uint (&hash_pos[56]);
+  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[5] = hex_to_u32 ((const u8 *) &hash_pos[40]);
+  digest[6] = hex_to_u32 ((const u8 *) &hash_pos[48]);
+  digest[7] = hex_to_u32 ((const u8 *) &hash_pos[56]);
 
   return (PARSER_OK);
 }
@@ -13598,10 +13584,10 @@ int mysql323_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_200) || (input_len > DISPLAY_LEN_MAX_200)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
+  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
   digest[2] = 0;
   digest[3] = 0;
 
@@ -13612,7 +13598,7 @@ int rakp_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_7300) || (input_len > DISPLAY_LEN_MAX_7300)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13645,7 +13631,7 @@ int rakp_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   for (i = 0, j = 0; i < saltbuf_len; i += 2, j += 1)
   {
-    rakp_ptr[j] = hex_to_char (&salt_ptr[i]);
+    rakp_ptr[j] = hex_to_u8 ((const u8 *) &salt_ptr[i]);
   }
 
   rakp_ptr[j] = 0x80;
@@ -13668,11 +13654,11 @@ int rakp_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = 32; // muss min. 32 haben
 
-  digest[0] = hex_to_uint (&hashbuf_pos[ 0]);
-  digest[1] = hex_to_uint (&hashbuf_pos[ 8]);
-  digest[2] = hex_to_uint (&hashbuf_pos[16]);
-  digest[3] = hex_to_uint (&hashbuf_pos[24]);
-  digest[4] = hex_to_uint (&hashbuf_pos[32]);
+  digest[0] = hex_to_u32 ((const u8 *) &hashbuf_pos[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &hashbuf_pos[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &hashbuf_pos[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &hashbuf_pos[24]);
+  digest[4] = hex_to_u32 ((const u8 *) &hashbuf_pos[32]);
 
   return (PARSER_OK);
 }
@@ -13681,7 +13667,7 @@ int netscaler_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_8100) || (input_len > DISPLAY_LEN_MAX_8100)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13698,11 +13684,11 @@ int netscaler_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *hash_pos = salt_pos + 8;
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
+  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;
@@ -13717,14 +13703,14 @@ int chap_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_4800) || (input_len > DISPLAY_LEN_MAX_4800)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -13740,12 +13726,12 @@ int chap_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *salt_buf_ptr = input_buf + 32 + 1;
 
-  uint32_t *salt_buf = salt->salt_buf;
+  u32 *salt_buf = salt->salt_buf;
 
-  salt_buf[0] = hex_to_uint (&salt_buf_ptr[ 0]);
-  salt_buf[1] = hex_to_uint (&salt_buf_ptr[ 8]);
-  salt_buf[2] = hex_to_uint (&salt_buf_ptr[16]);
-  salt_buf[3] = hex_to_uint (&salt_buf_ptr[24]);
+  salt_buf[0] = hex_to_u32 ((const u8 *) &salt_buf_ptr[ 0]);
+  salt_buf[1] = hex_to_u32 ((const u8 *) &salt_buf_ptr[ 8]);
+  salt_buf[2] = hex_to_u32 ((const u8 *) &salt_buf_ptr[16]);
+  salt_buf[3] = hex_to_u32 ((const u8 *) &salt_buf_ptr[24]);
 
   salt_buf[0] = byte_swap_32 (salt_buf[0]);
   salt_buf[1] = byte_swap_32 (salt_buf[1]);
@@ -13758,7 +13744,7 @@ int chap_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *idbyte_buf_ptr = input_buf + 32 + 1 + 32 + 1;
 
-  salt_buf[4] = hex_to_char (&idbyte_buf_ptr[0]) & 0xff;
+  salt_buf[4] = hex_to_u8 ((const u8 *) &idbyte_buf_ptr[0]) & 0xff;
 
   return (PARSER_OK);
 }
@@ -13767,7 +13753,7 @@ int cloudkey_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_8200) || (input_len > DISPLAY_LEN_MAX_8200)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13817,14 +13803,14 @@ int cloudkey_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // digest
 
-  digest[0] = hex_to_uint (&hashbuf_pos[ 0]);
-  digest[1] = hex_to_uint (&hashbuf_pos[ 8]);
-  digest[2] = hex_to_uint (&hashbuf_pos[16]);
-  digest[3] = hex_to_uint (&hashbuf_pos[24]);
-  digest[4] = hex_to_uint (&hashbuf_pos[32]);
-  digest[5] = hex_to_uint (&hashbuf_pos[40]);
-  digest[6] = hex_to_uint (&hashbuf_pos[48]);
-  digest[7] = hex_to_uint (&hashbuf_pos[56]);
+  digest[0] = hex_to_u32 ((const u8 *) &hashbuf_pos[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &hashbuf_pos[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &hashbuf_pos[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &hashbuf_pos[24]);
+  digest[4] = hex_to_u32 ((const u8 *) &hashbuf_pos[32]);
+  digest[5] = hex_to_u32 ((const u8 *) &hashbuf_pos[40]);
+  digest[6] = hex_to_u32 ((const u8 *) &hashbuf_pos[48]);
+  digest[7] = hex_to_u32 ((const u8 *) &hashbuf_pos[56]);
 
   // salt
 
@@ -13877,7 +13863,7 @@ int nsec3_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_8300) || (input_len > DISPLAY_LEN_MAX_8300)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -13934,9 +13920,9 @@ int nsec3_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   // and one that includes only the real salt (stored into salt_buf[]).
   // the domain-name length is put into array position 7 of salt_buf_pc[] since there is not salt_pc_len
 
-  char tmp_buf[100]; memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  base32_decode (itoa32_to_int, hashbuf_pos, 32, tmp_buf);
+  base32_decode (itoa32_to_int, (const u8 *) hashbuf_pos, 32, tmp_buf);
 
   memcpy (digest, tmp_buf, 20);
 
@@ -13991,15 +13977,15 @@ int wbb3_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_8400) || (input_len > DISPLAY_LEN_MAX_8400)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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]);
 
   if (input_buf[40] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
 
@@ -14020,7 +14006,7 @@ int wbb3_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
 int racf_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
-  const uint8_t ascii_to_ebcdic[] =
+  const u8 ascii_to_ebcdic[] =
   {
     0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
     0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
@@ -14044,7 +14030,7 @@ int racf_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_RACF, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14086,19 +14072,19 @@ int racf_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   IP (salt->salt_buf_pc[0], salt->salt_buf_pc[1], tt);
 
-  salt->salt_buf_pc[0] = ROTATE_LEFT (salt->salt_buf_pc[0], 3u);
-  salt->salt_buf_pc[1] = ROTATE_LEFT (salt->salt_buf_pc[1], 3u);
+  salt->salt_buf_pc[0] = rotl32 (salt->salt_buf_pc[0], 3u);
+  salt->salt_buf_pc[1] = rotl32 (salt->salt_buf_pc[1], 3u);
 
-  digest[0] = hex_to_uint (&digest_pos[ 0]);
-  digest[1] = hex_to_uint (&digest_pos[ 8]);
+  digest[0] = hex_to_u32 ((const u8 *) &digest_pos[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &digest_pos[ 8]);
 
   digest[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
 
   IP (digest[0], digest[1], tt);
 
-  digest[0] = ROTATE_RIGHT (digest[0], 29);
-  digest[1] = ROTATE_RIGHT (digest[1], 29);
+  digest[0] = rotr32 (digest[0], 29);
+  digest[1] = rotr32 (digest[1], 29);
   digest[2] = 0;
   digest[3] = 0;
 
@@ -14109,12 +14095,12 @@ int lotus5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_8600) || (input_len > DISPLAY_LEN_MAX_8600)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -14130,15 +14116,13 @@ int lotus6_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((input_buf[0] != '(') || (input_buf[1] != 'G') || (input_buf[21] != ')')) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  char tmp_buf[120];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[120] = { 0 };
 
-  base64_decode (lotus64_to_int, input_buf + 2, input_len - 3, tmp_buf);
+  base64_decode (lotus64_to_int, (const u8 *) input_buf + 2, input_len - 3, tmp_buf);
 
   tmp_buf[3] += -4; // dont ask!
 
@@ -14161,15 +14145,13 @@ int lotus8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((input_buf[0] != '(') || (input_buf[1] != 'H') || (input_buf[DISPLAY_LEN_MAX_9100 - 1] != ')')) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  char tmp_buf[120];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[120] = { 0 };
 
-  base64_decode (lotus64_to_int, input_buf + 2, input_len - 3, tmp_buf);
+  base64_decode (lotus64_to_int, (const u8 *) input_buf + 2, input_len - 3, tmp_buf);
 
   tmp_buf[3] += -4; // dont ask!
 
@@ -14181,7 +14163,7 @@ int lotus8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // iteration
 
-  char tmp_iter_buf[11];
+  char tmp_iter_buf[11] = { 0 };
 
   memcpy (tmp_iter_buf, tmp_buf + 16, 10);
 
@@ -14217,7 +14199,7 @@ int hmailserver_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_1421) || (input_len > DISPLAY_LEN_MAX_1421)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14225,14 +14207,14 @@ int hmailserver_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *hash_buf_pos = salt_buf_pos + 6;
 
-  digest[0] = hex_to_uint (&hash_buf_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_buf_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_buf_pos[16]);
-  digest[3] = hex_to_uint (&hash_buf_pos[24]);
-  digest[4] = hex_to_uint (&hash_buf_pos[32]);
-  digest[5] = hex_to_uint (&hash_buf_pos[40]);
-  digest[6] = hex_to_uint (&hash_buf_pos[48]);
-  digest[7] = hex_to_uint (&hash_buf_pos[56]);
+  digest[0] = hex_to_u32 ((const u8 *) &hash_buf_pos[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &hash_buf_pos[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &hash_buf_pos[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &hash_buf_pos[24]);
+  digest[4] = hex_to_u32 ((const u8 *) &hash_buf_pos[32]);
+  digest[5] = hex_to_u32 ((const u8 *) &hash_buf_pos[40]);
+  digest[6] = hex_to_u32 ((const u8 *) &hash_buf_pos[48]);
+  digest[7] = hex_to_u32 ((const u8 *) &hash_buf_pos[56]);
 
   digest[0] -= SHA256M_A;
   digest[1] -= SHA256M_B;
@@ -14258,7 +14240,7 @@ int phps_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_2612) || (input_len > DISPLAY_LEN_MAX_2612)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   if (memcmp (SIGNATURE_PHPS, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
@@ -14282,10 +14264,10 @@ int phps_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len;
 
-  digest[0] = hex_to_uint (&digest_buf[ 0]);
-  digest[1] = hex_to_uint (&digest_buf[ 8]);
-  digest[2] = hex_to_uint (&digest_buf[16]);
-  digest[3] = hex_to_uint (&digest_buf[24]);
+  digest[0] = hex_to_u32 ((const u8 *) &digest_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &digest_buf[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &digest_buf[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &digest_buf[24]);
 
   digest[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -14306,7 +14288,7 @@ int mediawiki_b_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_MEDIAWIKI_B, input_buf, 3)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14330,10 +14312,10 @@ int mediawiki_b_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len + 1;
 
-  digest[0] = hex_to_uint (&digest_buf[ 0]);
-  digest[1] = hex_to_uint (&digest_buf[ 8]);
-  digest[2] = hex_to_uint (&digest_buf[16]);
-  digest[3] = hex_to_uint (&digest_buf[24]);
+  digest[0] = hex_to_u32 ((const u8 *) &digest_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &digest_buf[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &digest_buf[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &digest_buf[24]);
 
   digest[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -14352,13 +14334,11 @@ int peoplesoft_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_133) || (input_len > DISPLAY_LEN_MAX_133)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
-
-  char tmp_buf[100];
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  base64_decode (base64_to_int, input_buf, input_len, tmp_buf);
+  base64_decode (base64_to_int, (const u8 *) input_buf, input_len, tmp_buf);
 
   memcpy (digest, tmp_buf, 20);
 
@@ -14381,14 +14361,14 @@ int skype_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_23) || (input_len > DISPLAY_LEN_MAX_23)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -14431,7 +14411,7 @@ int androidfde_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_ANDROIDFDE, input_buf, 5)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14491,15 +14471,15 @@ int androidfde_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * copy data
    */
 
-  digest[0] = hex_to_uint (&keybuf_pos[ 0]);
-  digest[1] = hex_to_uint (&keybuf_pos[ 8]);
-  digest[2] = hex_to_uint (&keybuf_pos[16]);
-  digest[3] = hex_to_uint (&keybuf_pos[24]);
+  digest[0] = hex_to_u32 ((const u8 *) &keybuf_pos[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &keybuf_pos[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &keybuf_pos[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &keybuf_pos[24]);
 
-  salt->salt_buf[0] = hex_to_uint (&saltbuf_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&saltbuf_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&saltbuf_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&saltbuf_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &saltbuf_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &saltbuf_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &saltbuf_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &saltbuf_pos[24]);
 
   salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]);
   salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]);
@@ -14511,7 +14491,7 @@ int androidfde_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   for (uint i = 0, j = 0; i < 3072; i += 8, j += 1)
   {
-    androidfde->data[j] = hex_to_uint (&databuf_pos[i]);
+    androidfde->data[j] = hex_to_u32 ((const u8 *) &databuf_pos[i]);
   }
 
   return (PARSER_OK);
@@ -14523,7 +14503,7 @@ int scrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SCRYPT, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14577,11 +14557,9 @@ int scrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // base64 decode
 
-  char tmp_buf[32];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[33] = { 0 };
 
-  int tmp_len = base64_decode (base64_to_int, saltbuf_pos, hash_pos - saltbuf_pos, tmp_buf);
+  int tmp_len = base64_decode (base64_to_int, (const u8 *) saltbuf_pos, hash_pos - saltbuf_pos, tmp_buf);
 
   char *salt_buf_ptr = (char *) salt->salt_buf;
 
@@ -14598,7 +14576,7 @@ int scrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (tmp_len != 44) return (PARSER_GLOBAL_LENGTH);
 
-  base64_decode (base64_to_int, hash_pos, tmp_len, tmp_buf);
+  base64_decode (base64_to_int, (const u8 *) hash_pos, tmp_len, tmp_buf);
 
   memcpy (digest, tmp_buf, 32);
 
@@ -14609,7 +14587,7 @@ int juniper_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_501) || (input_len > DISPLAY_LEN_MAX_501)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14617,7 +14595,7 @@ int juniper_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * parse line
    */
 
-  char decrypted[76]; // iv + hash
+  char decrypted[76] = { 0 }; // iv + hash
 
   juniper_decrypt_hash (input_buf, decrypted);
 
@@ -14648,7 +14626,7 @@ int cisco8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_CISCO8, input_buf, 3)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14691,13 +14669,11 @@ int cisco8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // base64 decode hash
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
   uint hash_len = input_len - 3 - salt_len - 1;
 
-  int tmp_len = base64_decode (itoa64_to_int, hash_pos, hash_len, tmp_buf);
+  int tmp_len = base64_decode (itoa64_to_int, (const u8 *) hash_pos, hash_len, tmp_buf);
 
   if (tmp_len != 32) return (PARSER_HASH_LENGTH);
 
@@ -14721,7 +14697,7 @@ int cisco9_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_CISCO9, input_buf, 3)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14751,13 +14727,11 @@ int cisco9_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // base64 decode hash
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
   uint hash_len = input_len - 3 - salt_len - 1;
 
-  int tmp_len = base64_decode (itoa64_to_int, hash_pos, hash_len, tmp_buf);
+  int tmp_len = base64_decode (itoa64_to_int, (const u8 *) hash_pos, hash_len, tmp_buf);
 
   if (tmp_len != 32) return (PARSER_HASH_LENGTH);
 
@@ -14778,7 +14752,7 @@ int office2007_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_OFFICE2007, input_buf, 8)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14794,7 +14768,7 @@ int office2007_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (verifierHashSize_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t version_len = verifierHashSize_pos - version_pos;
+  u32 version_len = verifierHashSize_pos - version_pos;
 
   if (version_len != 4) return (PARSER_SALT_LENGTH);
 
@@ -14804,7 +14778,7 @@ int office2007_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (keySize_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t verifierHashSize_len = keySize_pos - verifierHashSize_pos;
+  u32 verifierHashSize_len = keySize_pos - verifierHashSize_pos;
 
   if (verifierHashSize_len != 2) return (PARSER_SALT_LENGTH);
 
@@ -14814,7 +14788,7 @@ int office2007_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (saltSize_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t keySize_len = saltSize_pos - keySize_pos;
+  u32 keySize_len = saltSize_pos - keySize_pos;
 
   if (keySize_len != 3) return (PARSER_SALT_LENGTH);
 
@@ -14824,7 +14798,7 @@ int office2007_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (osalt_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t saltSize_len = osalt_pos - saltSize_pos;
+  u32 saltSize_len = osalt_pos - saltSize_pos;
 
   if (saltSize_len != 2) return (PARSER_SALT_LENGTH);
 
@@ -14834,7 +14808,7 @@ int office2007_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifier_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t osalt_len = encryptedVerifier_pos - osalt_pos;
+  u32 osalt_len = encryptedVerifier_pos - osalt_pos;
 
   if (osalt_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -14844,13 +14818,13 @@ int office2007_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifierHash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
+  u32 encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
 
   if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
 
   encryptedVerifierHash_pos++;
 
-  uint32_t encryptedVerifierHash_len = input_len - 8 - 1 - version_len - 1 - verifierHashSize_len - 1 - keySize_len - 1 - saltSize_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
+  u32 encryptedVerifierHash_len = input_len - 8 - 1 - version_len - 1 - verifierHashSize_len - 1 - keySize_len - 1 - saltSize_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
 
   if (encryptedVerifierHash_len != 40) return (PARSER_SALT_LENGTH);
 
@@ -14879,25 +14853,25 @@ int office2007_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   salt->salt_len  = 16;
   salt->salt_iter = ROUNDS_OFFICE2007;
 
-  salt->salt_buf[0] = hex_to_uint (&osalt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&osalt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&osalt_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&osalt_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &osalt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &osalt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &osalt_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &osalt_pos[24]);
 
   /**
    * esalt
    */
 
-  office2007->encryptedVerifier[0] = hex_to_uint (&encryptedVerifier_pos[ 0]);
-  office2007->encryptedVerifier[1] = hex_to_uint (&encryptedVerifier_pos[ 8]);
-  office2007->encryptedVerifier[2] = hex_to_uint (&encryptedVerifier_pos[16]);
-  office2007->encryptedVerifier[3] = hex_to_uint (&encryptedVerifier_pos[24]);
+  office2007->encryptedVerifier[0] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 0]);
+  office2007->encryptedVerifier[1] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 8]);
+  office2007->encryptedVerifier[2] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[16]);
+  office2007->encryptedVerifier[3] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[24]);
 
-  office2007->encryptedVerifierHash[0] = hex_to_uint (&encryptedVerifierHash_pos[ 0]);
-  office2007->encryptedVerifierHash[1] = hex_to_uint (&encryptedVerifierHash_pos[ 8]);
-  office2007->encryptedVerifierHash[2] = hex_to_uint (&encryptedVerifierHash_pos[16]);
-  office2007->encryptedVerifierHash[3] = hex_to_uint (&encryptedVerifierHash_pos[24]);
-  office2007->encryptedVerifierHash[4] = hex_to_uint (&encryptedVerifierHash_pos[32]);
+  office2007->encryptedVerifierHash[0] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 0]);
+  office2007->encryptedVerifierHash[1] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 8]);
+  office2007->encryptedVerifierHash[2] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[16]);
+  office2007->encryptedVerifierHash[3] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[24]);
+  office2007->encryptedVerifierHash[4] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[32]);
 
   /**
    * digest
@@ -14917,7 +14891,7 @@ int office2010_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_OFFICE2010, input_buf, 8)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -14933,7 +14907,7 @@ int office2010_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (spinCount_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t version_len = spinCount_pos - version_pos;
+  u32 version_len = spinCount_pos - version_pos;
 
   if (version_len != 4) return (PARSER_SALT_LENGTH);
 
@@ -14943,7 +14917,7 @@ int office2010_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (keySize_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t spinCount_len = keySize_pos - spinCount_pos;
+  u32 spinCount_len = keySize_pos - spinCount_pos;
 
   if (spinCount_len != 6) return (PARSER_SALT_LENGTH);
 
@@ -14953,7 +14927,7 @@ int office2010_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (saltSize_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t keySize_len = saltSize_pos - keySize_pos;
+  u32 keySize_len = saltSize_pos - keySize_pos;
 
   if (keySize_len != 3) return (PARSER_SALT_LENGTH);
 
@@ -14963,7 +14937,7 @@ int office2010_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (osalt_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t saltSize_len = osalt_pos - saltSize_pos;
+  u32 saltSize_len = osalt_pos - saltSize_pos;
 
   if (saltSize_len != 2) return (PARSER_SALT_LENGTH);
 
@@ -14973,7 +14947,7 @@ int office2010_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifier_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t osalt_len = encryptedVerifier_pos - osalt_pos;
+  u32 osalt_len = encryptedVerifier_pos - osalt_pos;
 
   if (osalt_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -14983,13 +14957,13 @@ int office2010_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifierHash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
+  u32 encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
 
   if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
 
   encryptedVerifierHash_pos++;
 
-  uint32_t encryptedVerifierHash_len = input_len - 8 - 1 - version_len - 1 - spinCount_len - 1 - keySize_len - 1 - saltSize_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
+  u32 encryptedVerifierHash_len = input_len - 8 - 1 - version_len - 1 - spinCount_len - 1 - keySize_len - 1 - saltSize_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
 
   if (encryptedVerifierHash_len != 64) return (PARSER_SALT_LENGTH);
 
@@ -15016,28 +14990,28 @@ int office2010_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   salt->salt_len  = 16;
   salt->salt_iter = spinCount;
 
-  salt->salt_buf[0] = hex_to_uint (&osalt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&osalt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&osalt_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&osalt_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &osalt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &osalt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &osalt_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &osalt_pos[24]);
 
   /**
    * esalt
    */
 
-  office2010->encryptedVerifier[0] = hex_to_uint (&encryptedVerifier_pos[ 0]);
-  office2010->encryptedVerifier[1] = hex_to_uint (&encryptedVerifier_pos[ 8]);
-  office2010->encryptedVerifier[2] = hex_to_uint (&encryptedVerifier_pos[16]);
-  office2010->encryptedVerifier[3] = hex_to_uint (&encryptedVerifier_pos[24]);
+  office2010->encryptedVerifier[0] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 0]);
+  office2010->encryptedVerifier[1] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 8]);
+  office2010->encryptedVerifier[2] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[16]);
+  office2010->encryptedVerifier[3] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[24]);
 
-  office2010->encryptedVerifierHash[0] = hex_to_uint (&encryptedVerifierHash_pos[ 0]);
-  office2010->encryptedVerifierHash[1] = hex_to_uint (&encryptedVerifierHash_pos[ 8]);
-  office2010->encryptedVerifierHash[2] = hex_to_uint (&encryptedVerifierHash_pos[16]);
-  office2010->encryptedVerifierHash[3] = hex_to_uint (&encryptedVerifierHash_pos[24]);
-  office2010->encryptedVerifierHash[4] = hex_to_uint (&encryptedVerifierHash_pos[32]);
-  office2010->encryptedVerifierHash[5] = hex_to_uint (&encryptedVerifierHash_pos[40]);
-  office2010->encryptedVerifierHash[6] = hex_to_uint (&encryptedVerifierHash_pos[48]);
-  office2010->encryptedVerifierHash[7] = hex_to_uint (&encryptedVerifierHash_pos[56]);
+  office2010->encryptedVerifierHash[0] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 0]);
+  office2010->encryptedVerifierHash[1] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 8]);
+  office2010->encryptedVerifierHash[2] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[16]);
+  office2010->encryptedVerifierHash[3] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[24]);
+  office2010->encryptedVerifierHash[4] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[32]);
+  office2010->encryptedVerifierHash[5] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[40]);
+  office2010->encryptedVerifierHash[6] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[48]);
+  office2010->encryptedVerifierHash[7] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[56]);
 
   /**
    * digest
@@ -15057,7 +15031,7 @@ int office2013_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_OFFICE2013, input_buf, 8)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -15073,7 +15047,7 @@ int office2013_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (spinCount_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t version_len = spinCount_pos - version_pos;
+  u32 version_len = spinCount_pos - version_pos;
 
   if (version_len != 4) return (PARSER_SALT_LENGTH);
 
@@ -15083,7 +15057,7 @@ int office2013_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (keySize_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t spinCount_len = keySize_pos - spinCount_pos;
+  u32 spinCount_len = keySize_pos - spinCount_pos;
 
   if (spinCount_len != 6) return (PARSER_SALT_LENGTH);
 
@@ -15093,7 +15067,7 @@ int office2013_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (saltSize_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t keySize_len = saltSize_pos - keySize_pos;
+  u32 keySize_len = saltSize_pos - keySize_pos;
 
   if (keySize_len != 3) return (PARSER_SALT_LENGTH);
 
@@ -15103,7 +15077,7 @@ int office2013_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (osalt_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t saltSize_len = osalt_pos - saltSize_pos;
+  u32 saltSize_len = osalt_pos - saltSize_pos;
 
   if (saltSize_len != 2) return (PARSER_SALT_LENGTH);
 
@@ -15113,7 +15087,7 @@ int office2013_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifier_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t osalt_len = encryptedVerifier_pos - osalt_pos;
+  u32 osalt_len = encryptedVerifier_pos - osalt_pos;
 
   if (osalt_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -15123,13 +15097,13 @@ int office2013_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifierHash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
+  u32 encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
 
   if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
 
   encryptedVerifierHash_pos++;
 
-  uint32_t encryptedVerifierHash_len = input_len - 8 - 1 - version_len - 1 - spinCount_len - 1 - keySize_len - 1 - saltSize_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
+  u32 encryptedVerifierHash_len = input_len - 8 - 1 - version_len - 1 - spinCount_len - 1 - keySize_len - 1 - saltSize_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
 
   if (encryptedVerifierHash_len != 64) return (PARSER_SALT_LENGTH);
 
@@ -15156,28 +15130,28 @@ int office2013_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   salt->salt_len  = 16;
   salt->salt_iter = spinCount;
 
-  salt->salt_buf[0] = hex_to_uint (&osalt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&osalt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&osalt_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&osalt_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &osalt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &osalt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &osalt_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &osalt_pos[24]);
 
   /**
    * esalt
    */
 
-  office2013->encryptedVerifier[0] = hex_to_uint (&encryptedVerifier_pos[ 0]);
-  office2013->encryptedVerifier[1] = hex_to_uint (&encryptedVerifier_pos[ 8]);
-  office2013->encryptedVerifier[2] = hex_to_uint (&encryptedVerifier_pos[16]);
-  office2013->encryptedVerifier[3] = hex_to_uint (&encryptedVerifier_pos[24]);
+  office2013->encryptedVerifier[0] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 0]);
+  office2013->encryptedVerifier[1] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 8]);
+  office2013->encryptedVerifier[2] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[16]);
+  office2013->encryptedVerifier[3] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[24]);
 
-  office2013->encryptedVerifierHash[0] = hex_to_uint (&encryptedVerifierHash_pos[ 0]);
-  office2013->encryptedVerifierHash[1] = hex_to_uint (&encryptedVerifierHash_pos[ 8]);
-  office2013->encryptedVerifierHash[2] = hex_to_uint (&encryptedVerifierHash_pos[16]);
-  office2013->encryptedVerifierHash[3] = hex_to_uint (&encryptedVerifierHash_pos[24]);
-  office2013->encryptedVerifierHash[4] = hex_to_uint (&encryptedVerifierHash_pos[32]);
-  office2013->encryptedVerifierHash[5] = hex_to_uint (&encryptedVerifierHash_pos[40]);
-  office2013->encryptedVerifierHash[6] = hex_to_uint (&encryptedVerifierHash_pos[48]);
-  office2013->encryptedVerifierHash[7] = hex_to_uint (&encryptedVerifierHash_pos[56]);
+  office2013->encryptedVerifierHash[0] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 0]);
+  office2013->encryptedVerifierHash[1] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 8]);
+  office2013->encryptedVerifierHash[2] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[16]);
+  office2013->encryptedVerifierHash[3] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[24]);
+  office2013->encryptedVerifierHash[4] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[32]);
+  office2013->encryptedVerifierHash[5] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[40]);
+  office2013->encryptedVerifierHash[6] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[48]);
+  office2013->encryptedVerifierHash[7] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[56]);
 
   /**
    * digest
@@ -15197,7 +15171,7 @@ int oldoffice01_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((memcmp (SIGNATURE_OLDOFFICE0, input_buf, 12)) && (memcmp (SIGNATURE_OLDOFFICE1, input_buf, 12))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -15213,7 +15187,7 @@ int oldoffice01_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (osalt_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t version_len = osalt_pos - version_pos;
+  u32 version_len = osalt_pos - version_pos;
 
   if (version_len != 1) return (PARSER_SALT_LENGTH);
 
@@ -15223,7 +15197,7 @@ int oldoffice01_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifier_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t osalt_len = encryptedVerifier_pos - osalt_pos;
+  u32 osalt_len = encryptedVerifier_pos - osalt_pos;
 
   if (osalt_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -15233,13 +15207,13 @@ int oldoffice01_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifierHash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
+  u32 encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
 
   if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
 
   encryptedVerifierHash_pos++;
 
-  uint32_t encryptedVerifierHash_len = input_len - 11 - version_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
+  u32 encryptedVerifierHash_len = input_len - 11 - version_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
 
   if (encryptedVerifierHash_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -15253,20 +15227,20 @@ int oldoffice01_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   oldoffice01->version = version;
 
-  oldoffice01->encryptedVerifier[0] = hex_to_uint (&encryptedVerifier_pos[ 0]);
-  oldoffice01->encryptedVerifier[1] = hex_to_uint (&encryptedVerifier_pos[ 8]);
-  oldoffice01->encryptedVerifier[2] = hex_to_uint (&encryptedVerifier_pos[16]);
-  oldoffice01->encryptedVerifier[3] = hex_to_uint (&encryptedVerifier_pos[24]);
+  oldoffice01->encryptedVerifier[0] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 0]);
+  oldoffice01->encryptedVerifier[1] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 8]);
+  oldoffice01->encryptedVerifier[2] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[16]);
+  oldoffice01->encryptedVerifier[3] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[24]);
 
   oldoffice01->encryptedVerifier[0] = byte_swap_32 (oldoffice01->encryptedVerifier[0]);
   oldoffice01->encryptedVerifier[1] = byte_swap_32 (oldoffice01->encryptedVerifier[1]);
   oldoffice01->encryptedVerifier[2] = byte_swap_32 (oldoffice01->encryptedVerifier[2]);
   oldoffice01->encryptedVerifier[3] = byte_swap_32 (oldoffice01->encryptedVerifier[3]);
 
-  oldoffice01->encryptedVerifierHash[0] = hex_to_uint (&encryptedVerifierHash_pos[ 0]);
-  oldoffice01->encryptedVerifierHash[1] = hex_to_uint (&encryptedVerifierHash_pos[ 8]);
-  oldoffice01->encryptedVerifierHash[2] = hex_to_uint (&encryptedVerifierHash_pos[16]);
-  oldoffice01->encryptedVerifierHash[3] = hex_to_uint (&encryptedVerifierHash_pos[24]);
+  oldoffice01->encryptedVerifierHash[0] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 0]);
+  oldoffice01->encryptedVerifierHash[1] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 8]);
+  oldoffice01->encryptedVerifierHash[2] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[16]);
+  oldoffice01->encryptedVerifierHash[3] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[24]);
 
   oldoffice01->encryptedVerifierHash[0] = byte_swap_32 (oldoffice01->encryptedVerifierHash[0]);
   oldoffice01->encryptedVerifierHash[1] = byte_swap_32 (oldoffice01->encryptedVerifierHash[1]);
@@ -15279,10 +15253,10 @@ int oldoffice01_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = 16;
 
-  salt->salt_buf[0] = hex_to_uint (&osalt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&osalt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&osalt_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&osalt_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &osalt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &osalt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &osalt_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &osalt_pos[24]);
 
   salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]);
   salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]);
@@ -15325,7 +15299,7 @@ int oldoffice01cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if ((memcmp (SIGNATURE_OLDOFFICE0, input_buf, 12)) && (memcmp (SIGNATURE_OLDOFFICE1, input_buf, 12))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -15341,7 +15315,7 @@ int oldoffice01cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (osalt_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t version_len = osalt_pos - version_pos;
+  u32 version_len = osalt_pos - version_pos;
 
   if (version_len != 1) return (PARSER_SALT_LENGTH);
 
@@ -15351,7 +15325,7 @@ int oldoffice01cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (encryptedVerifier_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t osalt_len = encryptedVerifier_pos - osalt_pos;
+  u32 osalt_len = encryptedVerifier_pos - osalt_pos;
 
   if (osalt_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -15361,7 +15335,7 @@ int oldoffice01cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (encryptedVerifierHash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
+  u32 encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
 
   if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -15371,13 +15345,13 @@ int oldoffice01cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (rc4key_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t encryptedVerifierHash_len = rc4key_pos - encryptedVerifierHash_pos;
+  u32 encryptedVerifierHash_len = rc4key_pos - encryptedVerifierHash_pos;
 
   if (encryptedVerifierHash_len != 32) return (PARSER_SALT_LENGTH);
 
   rc4key_pos++;
 
-  uint32_t rc4key_len = input_len - 11 - version_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1 - encryptedVerifierHash_len - 1;
+  u32 rc4key_len = input_len - 11 - version_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1 - encryptedVerifierHash_len - 1;
 
   if (rc4key_len != 10) return (PARSER_SALT_LENGTH);
 
@@ -15391,20 +15365,20 @@ int oldoffice01cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   oldoffice01->version = version;
 
-  oldoffice01->encryptedVerifier[0] = hex_to_uint (&encryptedVerifier_pos[ 0]);
-  oldoffice01->encryptedVerifier[1] = hex_to_uint (&encryptedVerifier_pos[ 8]);
-  oldoffice01->encryptedVerifier[2] = hex_to_uint (&encryptedVerifier_pos[16]);
-  oldoffice01->encryptedVerifier[3] = hex_to_uint (&encryptedVerifier_pos[24]);
+  oldoffice01->encryptedVerifier[0] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 0]);
+  oldoffice01->encryptedVerifier[1] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 8]);
+  oldoffice01->encryptedVerifier[2] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[16]);
+  oldoffice01->encryptedVerifier[3] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[24]);
 
   oldoffice01->encryptedVerifier[0] = byte_swap_32 (oldoffice01->encryptedVerifier[0]);
   oldoffice01->encryptedVerifier[1] = byte_swap_32 (oldoffice01->encryptedVerifier[1]);
   oldoffice01->encryptedVerifier[2] = byte_swap_32 (oldoffice01->encryptedVerifier[2]);
   oldoffice01->encryptedVerifier[3] = byte_swap_32 (oldoffice01->encryptedVerifier[3]);
 
-  oldoffice01->encryptedVerifierHash[0] = hex_to_uint (&encryptedVerifierHash_pos[ 0]);
-  oldoffice01->encryptedVerifierHash[1] = hex_to_uint (&encryptedVerifierHash_pos[ 8]);
-  oldoffice01->encryptedVerifierHash[2] = hex_to_uint (&encryptedVerifierHash_pos[16]);
-  oldoffice01->encryptedVerifierHash[3] = hex_to_uint (&encryptedVerifierHash_pos[24]);
+  oldoffice01->encryptedVerifierHash[0] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 0]);
+  oldoffice01->encryptedVerifierHash[1] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 8]);
+  oldoffice01->encryptedVerifierHash[2] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[16]);
+  oldoffice01->encryptedVerifierHash[3] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[24]);
 
   oldoffice01->encryptedVerifierHash[0] = byte_swap_32 (oldoffice01->encryptedVerifierHash[0]);
   oldoffice01->encryptedVerifierHash[1] = byte_swap_32 (oldoffice01->encryptedVerifierHash[1]);
@@ -15434,10 +15408,10 @@ int oldoffice01cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   salt->salt_len = 16;
 
-  salt->salt_buf[0] = hex_to_uint (&osalt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&osalt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&osalt_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&osalt_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &osalt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &osalt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &osalt_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &osalt_pos[24]);
 
   salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]);
   salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]);
@@ -15475,7 +15449,7 @@ int oldoffice34_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((memcmp (SIGNATURE_OLDOFFICE3, input_buf, 12)) && (memcmp (SIGNATURE_OLDOFFICE4, input_buf, 12))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -15491,7 +15465,7 @@ int oldoffice34_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (osalt_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t version_len = osalt_pos - version_pos;
+  u32 version_len = osalt_pos - version_pos;
 
   if (version_len != 1) return (PARSER_SALT_LENGTH);
 
@@ -15501,7 +15475,7 @@ int oldoffice34_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifier_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t osalt_len = encryptedVerifier_pos - osalt_pos;
+  u32 osalt_len = encryptedVerifier_pos - osalt_pos;
 
   if (osalt_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -15511,13 +15485,13 @@ int oldoffice34_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (encryptedVerifierHash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
+  u32 encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
 
   if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
 
   encryptedVerifierHash_pos++;
 
-  uint32_t encryptedVerifierHash_len = input_len - 11 - version_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
+  u32 encryptedVerifierHash_len = input_len - 11 - version_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1;
 
   if (encryptedVerifierHash_len != 40) return (PARSER_SALT_LENGTH);
 
@@ -15531,21 +15505,21 @@ int oldoffice34_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   oldoffice34->version = version;
 
-  oldoffice34->encryptedVerifier[0] = hex_to_uint (&encryptedVerifier_pos[ 0]);
-  oldoffice34->encryptedVerifier[1] = hex_to_uint (&encryptedVerifier_pos[ 8]);
-  oldoffice34->encryptedVerifier[2] = hex_to_uint (&encryptedVerifier_pos[16]);
-  oldoffice34->encryptedVerifier[3] = hex_to_uint (&encryptedVerifier_pos[24]);
+  oldoffice34->encryptedVerifier[0] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 0]);
+  oldoffice34->encryptedVerifier[1] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 8]);
+  oldoffice34->encryptedVerifier[2] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[16]);
+  oldoffice34->encryptedVerifier[3] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[24]);
 
   oldoffice34->encryptedVerifier[0] = byte_swap_32 (oldoffice34->encryptedVerifier[0]);
   oldoffice34->encryptedVerifier[1] = byte_swap_32 (oldoffice34->encryptedVerifier[1]);
   oldoffice34->encryptedVerifier[2] = byte_swap_32 (oldoffice34->encryptedVerifier[2]);
   oldoffice34->encryptedVerifier[3] = byte_swap_32 (oldoffice34->encryptedVerifier[3]);
 
-  oldoffice34->encryptedVerifierHash[0] = hex_to_uint (&encryptedVerifierHash_pos[ 0]);
-  oldoffice34->encryptedVerifierHash[1] = hex_to_uint (&encryptedVerifierHash_pos[ 8]);
-  oldoffice34->encryptedVerifierHash[2] = hex_to_uint (&encryptedVerifierHash_pos[16]);
-  oldoffice34->encryptedVerifierHash[3] = hex_to_uint (&encryptedVerifierHash_pos[24]);
-  oldoffice34->encryptedVerifierHash[4] = hex_to_uint (&encryptedVerifierHash_pos[32]);
+  oldoffice34->encryptedVerifierHash[0] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 0]);
+  oldoffice34->encryptedVerifierHash[1] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 8]);
+  oldoffice34->encryptedVerifierHash[2] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[16]);
+  oldoffice34->encryptedVerifierHash[3] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[24]);
+  oldoffice34->encryptedVerifierHash[4] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[32]);
 
   oldoffice34->encryptedVerifierHash[0] = byte_swap_32 (oldoffice34->encryptedVerifierHash[0]);
   oldoffice34->encryptedVerifierHash[1] = byte_swap_32 (oldoffice34->encryptedVerifierHash[1]);
@@ -15559,10 +15533,10 @@ int oldoffice34_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = 16;
 
-  salt->salt_buf[0] = hex_to_uint (&osalt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&osalt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&osalt_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&osalt_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &osalt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &osalt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &osalt_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &osalt_pos[24]);
 
   // this is a workaround as office produces multiple documents with the same salt
 
@@ -15602,7 +15576,7 @@ int oldoffice34cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (memcmp (SIGNATURE_OLDOFFICE3, input_buf, 12)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -15618,7 +15592,7 @@ int oldoffice34cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (osalt_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t version_len = osalt_pos - version_pos;
+  u32 version_len = osalt_pos - version_pos;
 
   if (version_len != 1) return (PARSER_SALT_LENGTH);
 
@@ -15628,7 +15602,7 @@ int oldoffice34cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (encryptedVerifier_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t osalt_len = encryptedVerifier_pos - osalt_pos;
+  u32 osalt_len = encryptedVerifier_pos - osalt_pos;
 
   if (osalt_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -15638,7 +15612,7 @@ int oldoffice34cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (encryptedVerifierHash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
+  u32 encryptedVerifier_len = encryptedVerifierHash_pos - encryptedVerifier_pos;
 
   if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -15648,13 +15622,13 @@ int oldoffice34cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (rc4key_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t encryptedVerifierHash_len = rc4key_pos - encryptedVerifierHash_pos;
+  u32 encryptedVerifierHash_len = rc4key_pos - encryptedVerifierHash_pos;
 
   if (encryptedVerifierHash_len != 40) return (PARSER_SALT_LENGTH);
 
   rc4key_pos++;
 
-  uint32_t rc4key_len = input_len - 11 - version_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1 - encryptedVerifierHash_len - 1;
+  u32 rc4key_len = input_len - 11 - version_len - 1 - osalt_len - 1 - encryptedVerifier_len - 1 - encryptedVerifierHash_len - 1;
 
   if (rc4key_len != 10) return (PARSER_SALT_LENGTH);
 
@@ -15668,21 +15642,21 @@ int oldoffice34cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   oldoffice34->version = version;
 
-  oldoffice34->encryptedVerifier[0] = hex_to_uint (&encryptedVerifier_pos[ 0]);
-  oldoffice34->encryptedVerifier[1] = hex_to_uint (&encryptedVerifier_pos[ 8]);
-  oldoffice34->encryptedVerifier[2] = hex_to_uint (&encryptedVerifier_pos[16]);
-  oldoffice34->encryptedVerifier[3] = hex_to_uint (&encryptedVerifier_pos[24]);
+  oldoffice34->encryptedVerifier[0] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 0]);
+  oldoffice34->encryptedVerifier[1] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[ 8]);
+  oldoffice34->encryptedVerifier[2] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[16]);
+  oldoffice34->encryptedVerifier[3] = hex_to_u32 ((const u8 *) &encryptedVerifier_pos[24]);
 
   oldoffice34->encryptedVerifier[0] = byte_swap_32 (oldoffice34->encryptedVerifier[0]);
   oldoffice34->encryptedVerifier[1] = byte_swap_32 (oldoffice34->encryptedVerifier[1]);
   oldoffice34->encryptedVerifier[2] = byte_swap_32 (oldoffice34->encryptedVerifier[2]);
   oldoffice34->encryptedVerifier[3] = byte_swap_32 (oldoffice34->encryptedVerifier[3]);
 
-  oldoffice34->encryptedVerifierHash[0] = hex_to_uint (&encryptedVerifierHash_pos[ 0]);
-  oldoffice34->encryptedVerifierHash[1] = hex_to_uint (&encryptedVerifierHash_pos[ 8]);
-  oldoffice34->encryptedVerifierHash[2] = hex_to_uint (&encryptedVerifierHash_pos[16]);
-  oldoffice34->encryptedVerifierHash[3] = hex_to_uint (&encryptedVerifierHash_pos[24]);
-  oldoffice34->encryptedVerifierHash[4] = hex_to_uint (&encryptedVerifierHash_pos[32]);
+  oldoffice34->encryptedVerifierHash[0] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 0]);
+  oldoffice34->encryptedVerifierHash[1] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[ 8]);
+  oldoffice34->encryptedVerifierHash[2] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[16]);
+  oldoffice34->encryptedVerifierHash[3] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[24]);
+  oldoffice34->encryptedVerifierHash[4] = hex_to_u32 ((const u8 *) &encryptedVerifierHash_pos[32]);
 
   oldoffice34->encryptedVerifierHash[0] = byte_swap_32 (oldoffice34->encryptedVerifierHash[0]);
   oldoffice34->encryptedVerifierHash[1] = byte_swap_32 (oldoffice34->encryptedVerifierHash[1]);
@@ -15713,10 +15687,10 @@ int oldoffice34cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   salt->salt_len = 16;
 
-  salt->salt_buf[0] = hex_to_uint (&osalt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&osalt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&osalt_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&osalt_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &osalt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &osalt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &osalt_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &osalt_pos[24]);
 
   // this is a workaround as office produces multiple documents with the same salt
 
@@ -15747,12 +15721,12 @@ int radmin2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_9900) || (input_len > DISPLAY_LEN_MAX_9900)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -15768,7 +15742,7 @@ int djangosha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((memcmp (SIGNATURE_DJANGOSHA1, input_buf, 5)) && (memcmp (SIGNATURE_DJANGOSHA1, input_buf, 5))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -15778,7 +15752,7 @@ int djangosha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (salt_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t signature_len = salt_pos - signature_pos;
+  u32 signature_len = salt_pos - signature_pos;
 
   if (signature_len != 4) return (PARSER_SIGNATURE_UNMATCHED);
 
@@ -15788,21 +15762,21 @@ int djangosha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_len = hash_pos - salt_pos;
+  u32 salt_len = hash_pos - salt_pos;
 
   if (salt_len > 32) return (PARSER_SALT_LENGTH);
 
   hash_pos++;
 
-  uint32_t hash_len = input_len - signature_len - 1 - salt_len - 1;
+  u32 hash_len = input_len - signature_len - 1 - salt_len - 1;
 
   if (hash_len != 40) return (PARSER_SALT_LENGTH);
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
+  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;
@@ -15825,7 +15799,7 @@ int djangopbkdf2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_DJANGOPBKDF2, input_buf, 14)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -15876,15 +15850,13 @@ int djangopbkdf2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // base64 decode hash
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
   uint hash_len = input_len - (hash_pos - input_buf);
 
   if (hash_len != 44) return (PARSER_HASH_LENGTH);
 
-  base64_decode (base64_to_int, hash_pos, hash_len, tmp_buf);
+  base64_decode (base64_to_int, (const u8 *) hash_pos, hash_len, tmp_buf);
 
   memcpy (digest, tmp_buf, 32);
 
@@ -15904,12 +15876,12 @@ int siphash_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_10100) || (input_len > DISPLAY_LEN_MAX_10100)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
+  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
   digest[2] = 0;
   digest[3] = 0;
 
@@ -15929,10 +15901,10 @@ int siphash_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *salt_buf = input_buf + 16 + 1 + 1 + 1 + 1 + 1;
 
-  salt->salt_buf[0] = hex_to_uint (&salt_buf[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&salt_buf[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&salt_buf[16]);
-  salt->salt_buf[3] = hex_to_uint (&salt_buf[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_buf[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_buf[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &salt_buf[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &salt_buf[24]);
 
   salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]);
   salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]);
@@ -15950,7 +15922,7 @@ int crammd5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_CRAM_MD5, input_buf, 10)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   cram_md5_t *cram_md5 = (cram_md5_t *) hash_buf->esalt;
 
@@ -15970,11 +15942,9 @@ int crammd5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // base64 decode salt
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  salt_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf);
+  salt_len = base64_decode (base64_to_int, (const u8 *) salt_pos, salt_len, tmp_buf);
 
   if (salt_len > 55) return (PARSER_SALT_LENGTH);
 
@@ -15988,18 +15958,18 @@ int crammd5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   memset (tmp_buf, 0, sizeof (tmp_buf));
 
-  hash_len = base64_decode (base64_to_int, hash_pos, hash_len, tmp_buf);
+  hash_len = base64_decode (base64_to_int, (const u8 *) hash_pos, hash_len, tmp_buf);
 
   uint user_len = hash_len - 32;
 
-  char *tmp_hash = tmp_buf + user_len;
+  const u8 *tmp_hash = tmp_buf + user_len;
 
   user_len--; // skip the trailing space
 
-  digest[0] = hex_to_uint (&tmp_hash[ 0]);
-  digest[1] = hex_to_uint (&tmp_hash[ 8]);
-  digest[2] = hex_to_uint (&tmp_hash[16]);
-  digest[3] = hex_to_uint (&tmp_hash[24]);
+  digest[0] = hex_to_u32 (&tmp_hash[ 0]);
+  digest[1] = hex_to_u32 (&tmp_hash[ 8]);
+  digest[2] = hex_to_u32 (&tmp_hash[16]);
+  digest[3] = hex_to_u32 (&tmp_hash[24]);
 
   digest[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -16020,13 +15990,13 @@ int saph_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SAPH_SHA1, input_buf, 10)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
   char *iter_pos = input_buf + 10;
 
-  uint32_t iter = atoi (iter_pos);
+  u32 iter = atoi (iter_pos);
 
   if (iter < 1)
   {
@@ -16048,13 +16018,11 @@ int saph_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // base64 decode salt
 
-  uint32_t base64_len = input_len - (base64_pos - input_buf);
-
-  char tmp_buf[100];
+  u32 base64_len = input_len - (base64_pos - input_buf);
 
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  uint32_t decoded_len = base64_decode (base64_to_int, base64_pos, base64_len, tmp_buf);
+  u32 decoded_len = base64_decode (base64_to_int, (const u8 *) base64_pos, base64_len, tmp_buf);
 
   if (decoded_len < 24)
   {
@@ -16074,7 +16042,7 @@ int saph_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // set digest
 
-  uint32_t *digest_ptr = (uint32_t*) tmp_buf;
+  u32 *digest_ptr = (u32*) tmp_buf;
 
   digest[0] = byte_swap_32 (digest_ptr[0]);
   digest[1] = byte_swap_32 (digest_ptr[1]);
@@ -16089,15 +16057,15 @@ int redmine_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_7600) || (input_len > DISPLAY_LEN_MAX_7600)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
+  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]);
 
   if (input_buf[40] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
 
@@ -16122,7 +16090,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((memcmp (SIGNATURE_PDF, input_buf, 5)) && (memcmp (SIGNATURE_PDF, input_buf, 5))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -16138,7 +16106,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (R_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t V_len = R_pos - V_pos;
+  u32 V_len = R_pos - V_pos;
 
   R_pos++;
 
@@ -16146,7 +16114,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (bits_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t R_len = bits_pos - R_pos;
+  u32 R_len = bits_pos - R_pos;
 
   bits_pos++;
 
@@ -16154,7 +16122,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (P_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t bits_len = P_pos - bits_pos;
+  u32 bits_len = P_pos - bits_pos;
 
   P_pos++;
 
@@ -16162,7 +16130,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (enc_md_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t P_len = enc_md_pos - P_pos;
+  u32 P_len = enc_md_pos - P_pos;
 
   enc_md_pos++;
 
@@ -16170,7 +16138,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (id_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t enc_md_len = id_len_pos - enc_md_pos;
+  u32 enc_md_len = id_len_pos - enc_md_pos;
 
   id_len_pos++;
 
@@ -16178,7 +16146,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (id_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t id_len_len = id_buf_pos - id_len_pos;
+  u32 id_len_len = id_buf_pos - id_len_pos;
 
   id_buf_pos++;
 
@@ -16186,7 +16154,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (u_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t id_buf_len = u_len_pos - id_buf_pos;
+  u32 id_buf_len = u_len_pos - id_buf_pos;
 
   if (id_buf_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -16196,7 +16164,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (u_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t u_len_len = u_buf_pos - u_len_pos;
+  u32 u_len_len = u_buf_pos - u_len_pos;
 
   u_buf_pos++;
 
@@ -16204,7 +16172,7 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (o_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t u_buf_len = o_len_pos - u_buf_pos;
+  u32 u_buf_len = o_len_pos - u_buf_pos;
 
   if (u_buf_len != 64) return (PARSER_SALT_LENGTH);
 
@@ -16214,11 +16182,11 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (o_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t o_len_len = o_buf_pos - o_len_pos;
+  u32 o_len_len = o_buf_pos - o_len_pos;
 
   o_buf_pos++;
 
-  uint32_t o_buf_len = input_len - 5 - V_len - 1 - R_len - 1 - bits_len - 1 - P_len - 1 - enc_md_len - 1 - id_len_len - 1 - id_buf_len - 1 - u_len_len - 1 - u_buf_len - 1 - o_len_len - 1;
+  u32 o_buf_len = input_len - 5 - V_len - 1 - R_len - 1 - bits_len - 1 - P_len - 1 - enc_md_len - 1 - id_len_len - 1 - id_buf_len - 1 - u_len_len - 1 - u_buf_len - 1 - o_len_len - 1;
 
   if (o_buf_len != 64) return (PARSER_SALT_LENGTH);
 
@@ -16255,30 +16223,30 @@ int pdf11_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   pdf->enc_md = enc_md;
 
-  pdf->id_buf[0] = hex_to_uint (&id_buf_pos[ 0]);
-  pdf->id_buf[1] = hex_to_uint (&id_buf_pos[ 8]);
-  pdf->id_buf[2] = hex_to_uint (&id_buf_pos[16]);
-  pdf->id_buf[3] = hex_to_uint (&id_buf_pos[24]);
+  pdf->id_buf[0] = hex_to_u32 ((const u8 *) &id_buf_pos[ 0]);
+  pdf->id_buf[1] = hex_to_u32 ((const u8 *) &id_buf_pos[ 8]);
+  pdf->id_buf[2] = hex_to_u32 ((const u8 *) &id_buf_pos[16]);
+  pdf->id_buf[3] = hex_to_u32 ((const u8 *) &id_buf_pos[24]);
   pdf->id_len    = id_len;
 
-  pdf->u_buf[0]  = hex_to_uint (&u_buf_pos[ 0]);
-  pdf->u_buf[1]  = hex_to_uint (&u_buf_pos[ 8]);
-  pdf->u_buf[2]  = hex_to_uint (&u_buf_pos[16]);
-  pdf->u_buf[3]  = hex_to_uint (&u_buf_pos[24]);
-  pdf->u_buf[4]  = hex_to_uint (&u_buf_pos[32]);
-  pdf->u_buf[5]  = hex_to_uint (&u_buf_pos[40]);
-  pdf->u_buf[6]  = hex_to_uint (&u_buf_pos[48]);
-  pdf->u_buf[7]  = hex_to_uint (&u_buf_pos[56]);
+  pdf->u_buf[0]  = hex_to_u32 ((const u8 *) &u_buf_pos[ 0]);
+  pdf->u_buf[1]  = hex_to_u32 ((const u8 *) &u_buf_pos[ 8]);
+  pdf->u_buf[2]  = hex_to_u32 ((const u8 *) &u_buf_pos[16]);
+  pdf->u_buf[3]  = hex_to_u32 ((const u8 *) &u_buf_pos[24]);
+  pdf->u_buf[4]  = hex_to_u32 ((const u8 *) &u_buf_pos[32]);
+  pdf->u_buf[5]  = hex_to_u32 ((const u8 *) &u_buf_pos[40]);
+  pdf->u_buf[6]  = hex_to_u32 ((const u8 *) &u_buf_pos[48]);
+  pdf->u_buf[7]  = hex_to_u32 ((const u8 *) &u_buf_pos[56]);
   pdf->u_len     = u_len;
 
-  pdf->o_buf[0]  = hex_to_uint (&o_buf_pos[ 0]);
-  pdf->o_buf[1]  = hex_to_uint (&o_buf_pos[ 8]);
-  pdf->o_buf[2]  = hex_to_uint (&o_buf_pos[16]);
-  pdf->o_buf[3]  = hex_to_uint (&o_buf_pos[24]);
-  pdf->o_buf[4]  = hex_to_uint (&o_buf_pos[32]);
-  pdf->o_buf[5]  = hex_to_uint (&o_buf_pos[40]);
-  pdf->o_buf[6]  = hex_to_uint (&o_buf_pos[48]);
-  pdf->o_buf[7]  = hex_to_uint (&o_buf_pos[56]);
+  pdf->o_buf[0]  = hex_to_u32 ((const u8 *) &o_buf_pos[ 0]);
+  pdf->o_buf[1]  = hex_to_u32 ((const u8 *) &o_buf_pos[ 8]);
+  pdf->o_buf[2]  = hex_to_u32 ((const u8 *) &o_buf_pos[16]);
+  pdf->o_buf[3]  = hex_to_u32 ((const u8 *) &o_buf_pos[24]);
+  pdf->o_buf[4]  = hex_to_u32 ((const u8 *) &o_buf_pos[32]);
+  pdf->o_buf[5]  = hex_to_u32 ((const u8 *) &o_buf_pos[40]);
+  pdf->o_buf[6]  = hex_to_u32 ((const u8 *) &o_buf_pos[48]);
+  pdf->o_buf[7]  = hex_to_u32 ((const u8 *) &o_buf_pos[56]);
   pdf->o_len     = o_len;
 
   pdf->id_buf[0] = byte_swap_32 (pdf->id_buf[0]);
@@ -16331,7 +16299,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((memcmp (SIGNATURE_PDF, input_buf, 5)) && (memcmp (SIGNATURE_PDF, input_buf, 5))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -16347,7 +16315,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (R_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t V_len = R_pos - V_pos;
+  u32 V_len = R_pos - V_pos;
 
   R_pos++;
 
@@ -16355,7 +16323,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (bits_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t R_len = bits_pos - R_pos;
+  u32 R_len = bits_pos - R_pos;
 
   bits_pos++;
 
@@ -16363,7 +16331,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (P_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t bits_len = P_pos - bits_pos;
+  u32 bits_len = P_pos - bits_pos;
 
   P_pos++;
 
@@ -16371,7 +16339,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (enc_md_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t P_len = enc_md_pos - P_pos;
+  u32 P_len = enc_md_pos - P_pos;
 
   enc_md_pos++;
 
@@ -16379,7 +16347,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (id_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t enc_md_len = id_len_pos - enc_md_pos;
+  u32 enc_md_len = id_len_pos - enc_md_pos;
 
   id_len_pos++;
 
@@ -16387,7 +16355,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (id_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t id_len_len = id_buf_pos - id_len_pos;
+  u32 id_len_len = id_buf_pos - id_len_pos;
 
   id_buf_pos++;
 
@@ -16395,7 +16363,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (u_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t id_buf_len = u_len_pos - id_buf_pos;
+  u32 id_buf_len = u_len_pos - id_buf_pos;
 
   if (id_buf_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -16405,7 +16373,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (u_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t u_len_len = u_buf_pos - u_len_pos;
+  u32 u_len_len = u_buf_pos - u_len_pos;
 
   u_buf_pos++;
 
@@ -16413,7 +16381,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (o_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t u_buf_len = o_len_pos - u_buf_pos;
+  u32 u_buf_len = o_len_pos - u_buf_pos;
 
   if (u_buf_len != 64) return (PARSER_SALT_LENGTH);
 
@@ -16423,7 +16391,7 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (o_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t o_len_len = o_buf_pos - o_len_pos;
+  u32 o_len_len = o_buf_pos - o_len_pos;
 
   o_buf_pos++;
 
@@ -16431,13 +16399,13 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (rc4key_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t o_buf_len = rc4key_pos - o_buf_pos;
+  u32 o_buf_len = rc4key_pos - o_buf_pos;
 
   if (o_buf_len != 64) return (PARSER_SALT_LENGTH);
 
   rc4key_pos++;
 
-  uint32_t rc4key_len = input_len - 5 - V_len - 1 - R_len - 1 - bits_len - 1 - P_len - 1 - enc_md_len - 1 - id_len_len - 1 - id_buf_len - 1 - u_len_len - 1 - u_buf_len - 1 - o_len_len - 1 - o_buf_len - 1;
+  u32 rc4key_len = input_len - 5 - V_len - 1 - R_len - 1 - bits_len - 1 - P_len - 1 - enc_md_len - 1 - id_len_len - 1 - id_buf_len - 1 - u_len_len - 1 - u_buf_len - 1 - o_len_len - 1 - o_buf_len - 1;
 
   if (rc4key_len != 10) return (PARSER_SALT_LENGTH);
 
@@ -16474,30 +16442,30 @@ int pdf11cm2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   pdf->enc_md = enc_md;
 
-  pdf->id_buf[0] = hex_to_uint (&id_buf_pos[ 0]);
-  pdf->id_buf[1] = hex_to_uint (&id_buf_pos[ 8]);
-  pdf->id_buf[2] = hex_to_uint (&id_buf_pos[16]);
-  pdf->id_buf[3] = hex_to_uint (&id_buf_pos[24]);
+  pdf->id_buf[0] = hex_to_u32 ((const u8 *) &id_buf_pos[ 0]);
+  pdf->id_buf[1] = hex_to_u32 ((const u8 *) &id_buf_pos[ 8]);
+  pdf->id_buf[2] = hex_to_u32 ((const u8 *) &id_buf_pos[16]);
+  pdf->id_buf[3] = hex_to_u32 ((const u8 *) &id_buf_pos[24]);
   pdf->id_len    = id_len;
 
-  pdf->u_buf[0]  = hex_to_uint (&u_buf_pos[ 0]);
-  pdf->u_buf[1]  = hex_to_uint (&u_buf_pos[ 8]);
-  pdf->u_buf[2]  = hex_to_uint (&u_buf_pos[16]);
-  pdf->u_buf[3]  = hex_to_uint (&u_buf_pos[24]);
-  pdf->u_buf[4]  = hex_to_uint (&u_buf_pos[32]);
-  pdf->u_buf[5]  = hex_to_uint (&u_buf_pos[40]);
-  pdf->u_buf[6]  = hex_to_uint (&u_buf_pos[48]);
-  pdf->u_buf[7]  = hex_to_uint (&u_buf_pos[56]);
+  pdf->u_buf[0]  = hex_to_u32 ((const u8 *) &u_buf_pos[ 0]);
+  pdf->u_buf[1]  = hex_to_u32 ((const u8 *) &u_buf_pos[ 8]);
+  pdf->u_buf[2]  = hex_to_u32 ((const u8 *) &u_buf_pos[16]);
+  pdf->u_buf[3]  = hex_to_u32 ((const u8 *) &u_buf_pos[24]);
+  pdf->u_buf[4]  = hex_to_u32 ((const u8 *) &u_buf_pos[32]);
+  pdf->u_buf[5]  = hex_to_u32 ((const u8 *) &u_buf_pos[40]);
+  pdf->u_buf[6]  = hex_to_u32 ((const u8 *) &u_buf_pos[48]);
+  pdf->u_buf[7]  = hex_to_u32 ((const u8 *) &u_buf_pos[56]);
   pdf->u_len     = u_len;
 
-  pdf->o_buf[0]  = hex_to_uint (&o_buf_pos[ 0]);
-  pdf->o_buf[1]  = hex_to_uint (&o_buf_pos[ 8]);
-  pdf->o_buf[2]  = hex_to_uint (&o_buf_pos[16]);
-  pdf->o_buf[3]  = hex_to_uint (&o_buf_pos[24]);
-  pdf->o_buf[4]  = hex_to_uint (&o_buf_pos[32]);
-  pdf->o_buf[5]  = hex_to_uint (&o_buf_pos[40]);
-  pdf->o_buf[6]  = hex_to_uint (&o_buf_pos[48]);
-  pdf->o_buf[7]  = hex_to_uint (&o_buf_pos[56]);
+  pdf->o_buf[0]  = hex_to_u32 ((const u8 *) &o_buf_pos[ 0]);
+  pdf->o_buf[1]  = hex_to_u32 ((const u8 *) &o_buf_pos[ 8]);
+  pdf->o_buf[2]  = hex_to_u32 ((const u8 *) &o_buf_pos[16]);
+  pdf->o_buf[3]  = hex_to_u32 ((const u8 *) &o_buf_pos[24]);
+  pdf->o_buf[4]  = hex_to_u32 ((const u8 *) &o_buf_pos[32]);
+  pdf->o_buf[5]  = hex_to_u32 ((const u8 *) &o_buf_pos[40]);
+  pdf->o_buf[6]  = hex_to_u32 ((const u8 *) &o_buf_pos[48]);
+  pdf->o_buf[7]  = hex_to_u32 ((const u8 *) &o_buf_pos[56]);
   pdf->o_len     = o_len;
 
   pdf->id_buf[0] = byte_swap_32 (pdf->id_buf[0]);
@@ -16566,7 +16534,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((memcmp (SIGNATURE_PDF, input_buf, 5)) && (memcmp (SIGNATURE_PDF, input_buf, 5))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -16582,7 +16550,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (R_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t V_len = R_pos - V_pos;
+  u32 V_len = R_pos - V_pos;
 
   R_pos++;
 
@@ -16590,7 +16558,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (bits_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t R_len = bits_pos - R_pos;
+  u32 R_len = bits_pos - R_pos;
 
   bits_pos++;
 
@@ -16598,7 +16566,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (P_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t bits_len = P_pos - bits_pos;
+  u32 bits_len = P_pos - bits_pos;
 
   P_pos++;
 
@@ -16606,7 +16574,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (enc_md_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t P_len = enc_md_pos - P_pos;
+  u32 P_len = enc_md_pos - P_pos;
 
   enc_md_pos++;
 
@@ -16614,7 +16582,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (id_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t enc_md_len = id_len_pos - enc_md_pos;
+  u32 enc_md_len = id_len_pos - enc_md_pos;
 
   id_len_pos++;
 
@@ -16622,7 +16590,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (id_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t id_len_len = id_buf_pos - id_len_pos;
+  u32 id_len_len = id_buf_pos - id_len_pos;
 
   id_buf_pos++;
 
@@ -16630,7 +16598,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (u_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t id_buf_len = u_len_pos - id_buf_pos;
+  u32 id_buf_len = u_len_pos - id_buf_pos;
 
   if ((id_buf_len != 32) && (id_buf_len != 64)) return (PARSER_SALT_LENGTH);
 
@@ -16640,7 +16608,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (u_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t u_len_len = u_buf_pos - u_len_pos;
+  u32 u_len_len = u_buf_pos - u_len_pos;
 
   u_buf_pos++;
 
@@ -16648,7 +16616,7 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (o_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t u_buf_len = o_len_pos - u_buf_pos;
+  u32 u_buf_len = o_len_pos - u_buf_pos;
 
   if (u_buf_len != 64) return (PARSER_SALT_LENGTH);
 
@@ -16658,11 +16626,11 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (o_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t o_len_len = o_buf_pos - o_len_pos;
+  u32 o_len_len = o_buf_pos - o_len_pos;
 
   o_buf_pos++;
 
-  uint32_t o_buf_len = input_len - 5 - V_len - 1 - R_len - 1 - bits_len - 1 - P_len - 1 - enc_md_len - 1 - id_len_len - 1 - id_buf_len - 1 - u_len_len - 1 - u_buf_len - 1 - o_len_len - 1;
+  u32 o_buf_len = input_len - 5 - V_len - 1 - R_len - 1 - bits_len - 1 - P_len - 1 - enc_md_len - 1 - id_len_len - 1 - id_buf_len - 1 - u_len_len - 1 - u_buf_len - 1 - o_len_len - 1;
 
   if (o_buf_len != 64) return (PARSER_SALT_LENGTH);
 
@@ -16707,39 +16675,39 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   pdf->enc_md = enc_md;
 
-  pdf->id_buf[0] = hex_to_uint (&id_buf_pos[ 0]);
-  pdf->id_buf[1] = hex_to_uint (&id_buf_pos[ 8]);
-  pdf->id_buf[2] = hex_to_uint (&id_buf_pos[16]);
-  pdf->id_buf[3] = hex_to_uint (&id_buf_pos[24]);
+  pdf->id_buf[0] = hex_to_u32 ((const u8 *) &id_buf_pos[ 0]);
+  pdf->id_buf[1] = hex_to_u32 ((const u8 *) &id_buf_pos[ 8]);
+  pdf->id_buf[2] = hex_to_u32 ((const u8 *) &id_buf_pos[16]);
+  pdf->id_buf[3] = hex_to_u32 ((const u8 *) &id_buf_pos[24]);
 
   if (id_len == 32)
   {
-    pdf->id_buf[4] = hex_to_uint (&id_buf_pos[32]);
-    pdf->id_buf[5] = hex_to_uint (&id_buf_pos[40]);
-    pdf->id_buf[6] = hex_to_uint (&id_buf_pos[48]);
-    pdf->id_buf[7] = hex_to_uint (&id_buf_pos[56]);
+    pdf->id_buf[4] = hex_to_u32 ((const u8 *) &id_buf_pos[32]);
+    pdf->id_buf[5] = hex_to_u32 ((const u8 *) &id_buf_pos[40]);
+    pdf->id_buf[6] = hex_to_u32 ((const u8 *) &id_buf_pos[48]);
+    pdf->id_buf[7] = hex_to_u32 ((const u8 *) &id_buf_pos[56]);
   }
 
   pdf->id_len = id_len;
 
-  pdf->u_buf[0]  = hex_to_uint (&u_buf_pos[ 0]);
-  pdf->u_buf[1]  = hex_to_uint (&u_buf_pos[ 8]);
-  pdf->u_buf[2]  = hex_to_uint (&u_buf_pos[16]);
-  pdf->u_buf[3]  = hex_to_uint (&u_buf_pos[24]);
-  pdf->u_buf[4]  = hex_to_uint (&u_buf_pos[32]);
-  pdf->u_buf[5]  = hex_to_uint (&u_buf_pos[40]);
-  pdf->u_buf[6]  = hex_to_uint (&u_buf_pos[48]);
-  pdf->u_buf[7]  = hex_to_uint (&u_buf_pos[56]);
+  pdf->u_buf[0]  = hex_to_u32 ((const u8 *) &u_buf_pos[ 0]);
+  pdf->u_buf[1]  = hex_to_u32 ((const u8 *) &u_buf_pos[ 8]);
+  pdf->u_buf[2]  = hex_to_u32 ((const u8 *) &u_buf_pos[16]);
+  pdf->u_buf[3]  = hex_to_u32 ((const u8 *) &u_buf_pos[24]);
+  pdf->u_buf[4]  = hex_to_u32 ((const u8 *) &u_buf_pos[32]);
+  pdf->u_buf[5]  = hex_to_u32 ((const u8 *) &u_buf_pos[40]);
+  pdf->u_buf[6]  = hex_to_u32 ((const u8 *) &u_buf_pos[48]);
+  pdf->u_buf[7]  = hex_to_u32 ((const u8 *) &u_buf_pos[56]);
   pdf->u_len     = u_len;
 
-  pdf->o_buf[0]  = hex_to_uint (&o_buf_pos[ 0]);
-  pdf->o_buf[1]  = hex_to_uint (&o_buf_pos[ 8]);
-  pdf->o_buf[2]  = hex_to_uint (&o_buf_pos[16]);
-  pdf->o_buf[3]  = hex_to_uint (&o_buf_pos[24]);
-  pdf->o_buf[4]  = hex_to_uint (&o_buf_pos[32]);
-  pdf->o_buf[5]  = hex_to_uint (&o_buf_pos[40]);
-  pdf->o_buf[6]  = hex_to_uint (&o_buf_pos[48]);
-  pdf->o_buf[7]  = hex_to_uint (&o_buf_pos[56]);
+  pdf->o_buf[0]  = hex_to_u32 ((const u8 *) &o_buf_pos[ 0]);
+  pdf->o_buf[1]  = hex_to_u32 ((const u8 *) &o_buf_pos[ 8]);
+  pdf->o_buf[2]  = hex_to_u32 ((const u8 *) &o_buf_pos[16]);
+  pdf->o_buf[3]  = hex_to_u32 ((const u8 *) &o_buf_pos[24]);
+  pdf->o_buf[4]  = hex_to_u32 ((const u8 *) &o_buf_pos[32]);
+  pdf->o_buf[5]  = hex_to_u32 ((const u8 *) &o_buf_pos[40]);
+  pdf->o_buf[6]  = hex_to_u32 ((const u8 *) &o_buf_pos[48]);
+  pdf->o_buf[7]  = hex_to_u32 ((const u8 *) &o_buf_pos[56]);
   pdf->o_len     = o_len;
 
   pdf->id_buf[0] = byte_swap_32 (pdf->id_buf[0]);
@@ -16789,14 +16757,14 @@ int pdf14_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // md5
 
-  uint salt_pc_block[32];
+  uint salt_pc_block[32] = { 0 };
 
   char *salt_pc_ptr = (char *) salt_pc_block;
 
   memcpy (salt_pc_ptr, padding, 32);
   memcpy (salt_pc_ptr + 32, pdf->id_buf, pdf->id_len);
 
-  uint salt_pc_digest[4];
+  uint salt_pc_digest[4] = { 0 };
 
   md5_complete_no_limit (salt_pc_digest, salt_pc_block, 32 + pdf->id_len);
 
@@ -16834,7 +16802,7 @@ int pdf17l3_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     return ret;
   }
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -16858,7 +16826,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if ((memcmp (SIGNATURE_PDF, input_buf, 5)) && (memcmp (SIGNATURE_PDF, input_buf, 5))) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -16874,7 +16842,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (R_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t V_len = R_pos - V_pos;
+  u32 V_len = R_pos - V_pos;
 
   R_pos++;
 
@@ -16882,7 +16850,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (bits_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t R_len = bits_pos - R_pos;
+  u32 R_len = bits_pos - R_pos;
 
   bits_pos++;
 
@@ -16890,7 +16858,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (P_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t bits_len = P_pos - bits_pos;
+  u32 bits_len = P_pos - bits_pos;
 
   P_pos++;
 
@@ -16898,7 +16866,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (enc_md_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t P_len = enc_md_pos - P_pos;
+  u32 P_len = enc_md_pos - P_pos;
 
   enc_md_pos++;
 
@@ -16906,7 +16874,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (id_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t enc_md_len = id_len_pos - enc_md_pos;
+  u32 enc_md_len = id_len_pos - enc_md_pos;
 
   id_len_pos++;
 
@@ -16914,7 +16882,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (id_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t id_len_len = id_buf_pos - id_len_pos;
+  u32 id_len_len = id_buf_pos - id_len_pos;
 
   id_buf_pos++;
 
@@ -16922,7 +16890,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (u_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t id_buf_len = u_len_pos - id_buf_pos;
+  u32 id_buf_len = u_len_pos - id_buf_pos;
 
   u_len_pos++;
 
@@ -16930,7 +16898,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (u_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t u_len_len = u_buf_pos - u_len_pos;
+  u32 u_len_len = u_buf_pos - u_len_pos;
 
   u_buf_pos++;
 
@@ -16938,7 +16906,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (o_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t u_buf_len = o_len_pos - u_buf_pos;
+  u32 u_buf_len = o_len_pos - u_buf_pos;
 
   o_len_pos++;
 
@@ -16946,7 +16914,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (o_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t o_len_len = o_buf_pos - o_len_pos;
+  u32 o_len_len = o_buf_pos - o_len_pos;
 
   o_buf_pos++;
 
@@ -16954,7 +16922,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (last == NULL) last = input_buf + input_len;
 
-  uint32_t o_buf_len = last - o_buf_pos;
+  u32 o_buf_len = last - o_buf_pos;
 
   // validate data
 
@@ -16999,7 +16967,7 @@ int pdf17l8_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   for (int i = 0, j = 0; i < 8 + 2; i += 1, j += 8)
   {
-    pdf->u_buf[i] = hex_to_uint (&u_buf_pos[j]);
+    pdf->u_buf[i] = hex_to_u32 ((const u8 *) &u_buf_pos[j]);
   }
 
   salt->salt_buf[0] = pdf->u_buf[8];
@@ -17029,7 +16997,7 @@ int pbkdf2_sha256_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_PBKDF2_SHA256, input_buf, 7)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -17043,7 +17011,7 @@ int pbkdf2_sha256_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *iter_pos = input_buf + 7;
 
-  uint32_t iter = atoi (iter_pos);
+  u32 iter = atoi (iter_pos);
 
   if (iter <      1) return (PARSER_SALT_ITERATION);
   if (iter > 999999) return (PARSER_SALT_ITERATION);
@@ -17060,13 +17028,13 @@ int pbkdf2_sha256_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_len = hash_pos - salt_pos;
+  u32 salt_len = hash_pos - salt_pos;
 
   if (salt_len > 64) return (PARSER_SALT_LENGTH);
 
   hash_pos++;
 
-  uint32_t hash_b64_len = input_len - (hash_pos - input_buf);
+  u32 hash_b64_len = input_len - (hash_pos - input_buf);
 
   if (hash_b64_len > 88) return (PARSER_HASH_LENGTH);
 
@@ -17086,11 +17054,9 @@ int pbkdf2_sha256_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // decode hash
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  int hash_len = base64_decode (base64_to_int, hash_pos, hash_b64_len, tmp_buf);
+  int hash_len = base64_decode (base64_to_int, (const u8 *) hash_pos, hash_b64_len, tmp_buf);
 
   if (hash_len < 16) return (PARSER_HASH_LENGTH);
 
@@ -17116,14 +17082,14 @@ int prestashop_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_11000) || (input_len > DISPLAY_LEN_MAX_11000)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -17153,7 +17119,7 @@ int postgresql_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_bu
 
   if (memcmp (SIGNATURE_POSTGRESQL_AUTH, input_buf, 10)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -17183,10 +17149,10 @@ int postgresql_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_bu
    * store digest
    */
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
+  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[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -17206,10 +17172,10 @@ int postgresql_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_bu
 
   // first 4 bytes are the "challenge"
 
-  salt_buf_ptr[0] = hex_to_char (&salt_pos[0]);
-  salt_buf_ptr[1] = hex_to_char (&salt_pos[2]);
-  salt_buf_ptr[2] = hex_to_char (&salt_pos[4]);
-  salt_buf_ptr[3] = hex_to_char (&salt_pos[6]);
+  salt_buf_ptr[0] = hex_to_u8 ((const u8 *) &salt_pos[0]);
+  salt_buf_ptr[1] = hex_to_u8 ((const u8 *) &salt_pos[2]);
+  salt_buf_ptr[2] = hex_to_u8 ((const u8 *) &salt_pos[4]);
+  salt_buf_ptr[3] = hex_to_u8 ((const u8 *) &salt_pos[6]);
 
   // append the user name
 
@@ -17226,7 +17192,7 @@ int mysql_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_MYSQL_AUTH, input_buf, 9)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -17250,11 +17216,11 @@ int mysql_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * store digest
    */
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
+  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]);
 
   /*
    * store salt
@@ -17275,7 +17241,7 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (memcmp (SIGNATURE_BITCOIN_WALLET, input_buf, 9)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -17291,7 +17257,7 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (cry_master_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t cry_master_len_len = cry_master_buf_pos - cry_master_len_pos;
+  u32 cry_master_len_len = cry_master_buf_pos - cry_master_len_pos;
 
   cry_master_buf_pos++;
 
@@ -17299,7 +17265,7 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (cry_salt_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t cry_master_buf_len = cry_salt_len_pos - cry_master_buf_pos;
+  u32 cry_master_buf_len = cry_salt_len_pos - cry_master_buf_pos;
 
   cry_salt_len_pos++;
 
@@ -17307,7 +17273,7 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (cry_salt_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t cry_salt_len_len = cry_salt_buf_pos - cry_salt_len_pos;
+  u32 cry_salt_len_len = cry_salt_buf_pos - cry_salt_len_pos;
 
   cry_salt_buf_pos++;
 
@@ -17315,7 +17281,7 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (cry_rounds_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t cry_salt_buf_len = cry_rounds_pos - cry_salt_buf_pos;
+  u32 cry_salt_buf_len = cry_rounds_pos - cry_salt_buf_pos;
 
   cry_rounds_pos++;
 
@@ -17323,7 +17289,7 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (ckey_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t cry_rounds_len = ckey_len_pos - cry_rounds_pos;
+  u32 cry_rounds_len = ckey_len_pos - cry_rounds_pos;
 
   ckey_len_pos++;
 
@@ -17331,7 +17297,7 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (ckey_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t ckey_len_len = ckey_buf_pos - ckey_len_pos;
+  u32 ckey_len_len = ckey_buf_pos - ckey_len_pos;
 
   ckey_buf_pos++;
 
@@ -17339,7 +17305,7 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (public_key_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t ckey_buf_len = public_key_len_pos - ckey_buf_pos;
+  u32 ckey_buf_len = public_key_len_pos - ckey_buf_pos;
 
   public_key_len_pos++;
 
@@ -17347,11 +17313,11 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
 
   if (public_key_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t public_key_len_len = public_key_buf_pos - public_key_len_pos;
+  u32 public_key_len_len = public_key_buf_pos - public_key_len_pos;
 
   public_key_buf_pos++;
 
-  uint32_t public_key_buf_len = input_len - 1 - 7 - 1 - cry_master_len_len - 1 - cry_master_buf_len - 1 - cry_salt_len_len - 1 - cry_salt_buf_len - 1 - cry_rounds_len - 1 - ckey_len_len - 1 - ckey_buf_len - 1 - public_key_len_len - 1;
+  u32 public_key_buf_len = input_len - 1 - 7 - 1 - cry_master_len_len - 1 - cry_master_buf_len - 1 - cry_salt_len_len - 1 - cry_salt_buf_len - 1 - cry_rounds_len - 1 - ckey_len_len - 1 - ckey_buf_len - 1 - public_key_len_len - 1;
 
   const uint cry_master_len = atoi (cry_master_len_pos);
   const uint cry_salt_len   = atoi (cry_salt_len_pos);
@@ -17363,23 +17329,23 @@ int bitcoin_wallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf
   if (ckey_buf_len       != ckey_len)       return (PARSER_SALT_VALUE);
   if (public_key_buf_len != public_key_len) return (PARSER_SALT_VALUE);
 
-  for (uint i = 0, j = 0; i < cry_master_len; i += 1, j += 8)
+  for (uint i = 0, j = 0; j < cry_master_len; i += 1, j += 8)
   {
-    bitcoin_wallet->cry_master_buf[i] = hex_to_uint (&cry_master_buf_pos[j]);
+    bitcoin_wallet->cry_master_buf[i] = hex_to_u32 ((const u8 *) &cry_master_buf_pos[j]);
 
     bitcoin_wallet->cry_master_buf[i] = byte_swap_32 (bitcoin_wallet->cry_master_buf[i]);
   }
 
-  for (uint i = 0, j = 0; i < ckey_len; i += 1, j += 8)
+  for (uint i = 0, j = 0; j < ckey_len; i += 1, j += 8)
   {
-    bitcoin_wallet->ckey_buf[i] = hex_to_uint (&ckey_buf_pos[j]);
+    bitcoin_wallet->ckey_buf[i] = hex_to_u32 ((const u8 *) &ckey_buf_pos[j]);
 
     bitcoin_wallet->ckey_buf[i] = byte_swap_32 (bitcoin_wallet->ckey_buf[i]);
   }
 
-  for (uint i = 0, j = 0; i < public_key_len; i += 1, j += 8)
+  for (uint i = 0, j = 0; j < public_key_len; i += 1, j += 8)
   {
-    bitcoin_wallet->public_key_buf[i] = hex_to_uint (&public_key_buf_pos[j]);
+    bitcoin_wallet->public_key_buf[i] = hex_to_u32 ((const u8 *) &public_key_buf_pos[j]);
 
     bitcoin_wallet->public_key_buf[i] = byte_swap_32 (bitcoin_wallet->public_key_buf[i]);
   }
@@ -17422,7 +17388,7 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SIP_AUTH, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -17430,9 +17396,8 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // work with a temporary copy of input_buf (s.t. we can manipulate it directly)
 
-  char temp_input_buf[input_len + 1];
+  char *temp_input_buf = (char *) mymalloc (input_len + 1);
 
-  memset (temp_input_buf, 0, sizeof (temp_input_buf));
   memcpy (temp_input_buf, input_buf, input_len);
 
   // URI_server:
@@ -17441,177 +17406,307 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *URI_client_pos = strchr (URI_server_pos, '*');
 
-  if (URI_client_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (URI_client_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   URI_client_pos[0] = 0;
   URI_client_pos++;
 
   uint URI_server_len = strlen (URI_server_pos);
 
-  if (URI_server_len > 512) return (PARSER_SALT_LENGTH);
+  if (URI_server_len > 512)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // URI_client:
 
   char *user_pos = strchr (URI_client_pos, '*');
 
-  if (user_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (user_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   user_pos[0] = 0;
   user_pos++;
 
   uint URI_client_len = strlen (URI_client_pos);
 
-  if (URI_client_len > 512) return (PARSER_SALT_LENGTH);
+  if (URI_client_len > 512)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // user:
 
   char *realm_pos = strchr (user_pos, '*');
 
-  if (realm_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (realm_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   realm_pos[0] = 0;
   realm_pos++;
 
   uint user_len = strlen (user_pos);
 
-  if (user_len > 116) return (PARSER_SALT_LENGTH);
+  if (user_len > 116)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // realm:
 
   char *method_pos = strchr (realm_pos, '*');
 
-  if (method_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (method_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   method_pos[0] = 0;
   method_pos++;
 
   uint realm_len = strlen (realm_pos);
 
-  if (realm_len > 116) return (PARSER_SALT_LENGTH);
+  if (realm_len > 116)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // method:
 
   char *URI_prefix_pos = strchr (method_pos, '*');
 
-  if (URI_prefix_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (URI_prefix_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   URI_prefix_pos[0] = 0;
   URI_prefix_pos++;
 
   uint method_len = strlen (method_pos);
 
-  if (method_len > 246) return (PARSER_SALT_LENGTH);
+  if (method_len > 246)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // URI_prefix:
 
   char *URI_resource_pos = strchr (URI_prefix_pos, '*');
 
-  if (URI_resource_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (URI_resource_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   URI_resource_pos[0] = 0;
   URI_resource_pos++;
 
   uint URI_prefix_len = strlen (URI_prefix_pos);
 
-  if (URI_prefix_len > 245) return (PARSER_SALT_LENGTH);
+  if (URI_prefix_len > 245)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // URI_resource:
 
   char *URI_suffix_pos = strchr (URI_resource_pos, '*');
 
-  if (URI_suffix_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (URI_suffix_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   URI_suffix_pos[0] = 0;
   URI_suffix_pos++;
 
   uint URI_resource_len = strlen (URI_resource_pos);
 
-  if (URI_resource_len <   1) return (PARSER_SALT_LENGTH);
-  if (URI_resource_len > 246) return (PARSER_SALT_LENGTH);
+  if (URI_resource_len < 1 || URI_resource_len > 246)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // URI_suffix:
 
   char *nonce_pos = strchr (URI_suffix_pos, '*');
 
-  if (nonce_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (nonce_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   nonce_pos[0] = 0;
   nonce_pos++;
 
   uint URI_suffix_len = strlen (URI_suffix_pos);
 
-  if (URI_suffix_len > 245) return (PARSER_SALT_LENGTH);
+  if (URI_suffix_len > 245)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // nonce:
 
   char *nonce_client_pos = strchr (nonce_pos, '*');
 
-  if (nonce_client_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (nonce_client_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   nonce_client_pos[0] = 0;
   nonce_client_pos++;
 
   uint nonce_len = strlen (nonce_pos);
 
-  if (nonce_len <  1) return (PARSER_SALT_LENGTH);
-  if (nonce_len > 50) return (PARSER_SALT_LENGTH);
+  if (nonce_len < 1 || nonce_len > 50)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // nonce_client:
 
   char *nonce_count_pos = strchr (nonce_client_pos, '*');
 
-  if (nonce_count_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (nonce_count_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   nonce_count_pos[0] = 0;
   nonce_count_pos++;
 
   uint nonce_client_len = strlen (nonce_client_pos);
 
-  if (nonce_client_len > 50) return (PARSER_SALT_LENGTH);
+  if (nonce_client_len > 50)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // nonce_count:
 
   char *qop_pos = strchr (nonce_count_pos, '*');
 
-  if (qop_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (qop_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   qop_pos[0] = 0;
   qop_pos++;
 
   uint nonce_count_len = strlen (nonce_count_pos);
 
-  if (nonce_count_len > 50) return (PARSER_SALT_LENGTH);
+  if (nonce_count_len > 50)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // qop:
 
   char *directive_pos = strchr (qop_pos, '*');
 
-  if (directive_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (directive_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   directive_pos[0] = 0;
   directive_pos++;
 
   uint qop_len = strlen (qop_pos);
 
-  if (qop_len > 50) return (PARSER_SALT_LENGTH);
+  if (qop_len > 50)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   // directive
 
   char *digest_pos = strchr (directive_pos, '*');
 
-  if (digest_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+  if (digest_pos == NULL)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SEPARATOR_UNMATCHED);
+  }
 
   digest_pos[0] = 0;
   digest_pos++;
 
   uint directive_len = strlen (directive_pos);
 
-  if (directive_len != 3) return (PARSER_SALT_LENGTH);
+  if (directive_len != 3)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   if (memcmp (directive_pos, "MD5", 3))
   {
     log_info ("ERROR: only the MD5 directive is currently supported\n");
 
+    myfree (temp_input_buf);
+
     return (PARSER_SIP_AUTH_DIRECTIVE);
   }
 
@@ -17625,9 +17720,7 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   uint md5_remaining_len = md5_max_len;
 
-  uint tmp_md5_buf[md5_max_len / 4];
-
-  memset (tmp_md5_buf, 0, sizeof (tmp_md5_buf));
+  uint tmp_md5_buf[64] = { 0 };
 
   char *tmp_md5_ptr = (char *) tmp_md5_buf;
 
@@ -17662,7 +17755,7 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     md5_len += 1 + URI_suffix_len;
   }
 
-  uint tmp_digest[4];
+  uint tmp_digest[4] = { 0 };
 
   md5_complete_no_limit (tmp_digest, tmp_md5_buf, md5_len);
 
@@ -17687,7 +17780,12 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   {
     esalt_len = 1 + nonce_len + 1 + nonce_count_len + 1 + nonce_client_len + 1 + qop_len + 1 + 32;
 
-    if (esalt_len > max_esalt_len) return (PARSER_SALT_LENGTH);
+    if (esalt_len > max_esalt_len)
+    {
+      myfree (temp_input_buf);
+
+      return (PARSER_SALT_LENGTH);
+    }
 
     snprintf (esalt_buf_ptr, max_esalt_len, ":%s:%s:%s:%s:%08x%08x%08x%08x",
       nonce_pos,
@@ -17703,7 +17801,12 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   {
     esalt_len = 1 + nonce_len + 1 + 32;
 
-    if (esalt_len > max_esalt_len) return (PARSER_SALT_LENGTH);
+    if (esalt_len > max_esalt_len)
+    {
+      myfree (temp_input_buf);
+
+      return (PARSER_SALT_LENGTH);
+    }
 
     snprintf (esalt_buf_ptr, max_esalt_len, ":%s:%08x%08x%08x%08x",
       nonce_pos,
@@ -17729,7 +17832,12 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   uint max_salt_len = 119;
 
-  if (salt_len > max_salt_len) return (PARSER_SALT_LENGTH);
+  if (salt_len > max_salt_len)
+  {
+    myfree (temp_input_buf);
+
+    return (PARSER_SALT_LENGTH);
+  }
 
   snprintf (sip_salt_ptr, max_salt_len + 1, "%s:%s:", user_pos, realm_pos);
 
@@ -17758,16 +17866,18 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * digest
    */
 
-  digest[0] = hex_to_uint (&digest_pos[ 0]);
-  digest[1] = hex_to_uint (&digest_pos[ 8]);
-  digest[2] = hex_to_uint (&digest_pos[16]);
-  digest[3] = hex_to_uint (&digest_pos[24]);
+  digest[0] = hex_to_u32 ((const u8 *) &digest_pos[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &digest_pos[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &digest_pos[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &digest_pos[24]);
 
   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]);
 
+  myfree (temp_input_buf);
+
   return (PARSER_OK);
 }
 
@@ -17777,7 +17887,7 @@ int crc32_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (input_buf[8] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -17785,7 +17895,7 @@ int crc32_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *digest_pos = input_buf;
 
-  digest[0] = hex_to_uint (&digest_pos[0]);
+  digest[0] = hex_to_u32 ((const u8 *) &digest_pos[0]);
   digest[1] = 0;
   digest[2] = 0;
   digest[3] = 0;
@@ -17813,7 +17923,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_SEVEN_ZIP, input_buf, 4)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -17829,7 +17939,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (NumCyclesPower_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t p_buf_len = NumCyclesPower_pos - p_buf_pos;
+  u32 p_buf_len = NumCyclesPower_pos - p_buf_pos;
 
   NumCyclesPower_pos++;
 
@@ -17837,7 +17947,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (salt_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t NumCyclesPower_len = salt_len_pos - NumCyclesPower_pos;
+  u32 NumCyclesPower_len = salt_len_pos - NumCyclesPower_pos;
 
   salt_len_pos++;
 
@@ -17845,7 +17955,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (salt_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_len_len = salt_buf_pos - salt_len_pos;
+  u32 salt_len_len = salt_buf_pos - salt_len_pos;
 
   salt_buf_pos++;
 
@@ -17853,7 +17963,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (iv_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_buf_len = iv_len_pos - salt_buf_pos;
+  u32 salt_buf_len = iv_len_pos - salt_buf_pos;
 
   iv_len_pos++;
 
@@ -17861,7 +17971,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (iv_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t iv_len_len = iv_buf_pos - iv_len_pos;
+  u32 iv_len_len = iv_buf_pos - iv_len_pos;
 
   iv_buf_pos++;
 
@@ -17869,7 +17979,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (crc_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t iv_buf_len = crc_buf_pos - iv_buf_pos;
+  u32 iv_buf_len = crc_buf_pos - iv_buf_pos;
 
   crc_buf_pos++;
 
@@ -17877,7 +17987,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (data_len_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t crc_buf_len = data_len_pos - crc_buf_pos;
+  u32 crc_buf_len = data_len_pos - crc_buf_pos;
 
   data_len_pos++;
 
@@ -17885,7 +17995,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (unpack_size_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t data_len_len = unpack_size_pos - data_len_pos;
+  u32 data_len_len = unpack_size_pos - data_len_pos;
 
   unpack_size_pos++;
 
@@ -17893,11 +18003,11 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (data_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t unpack_size_len = data_buf_pos - unpack_size_pos;
+  u32 unpack_size_len = data_buf_pos - unpack_size_pos;
 
   data_buf_pos++;
 
-  uint32_t data_buf_len = input_len - 1 - 2 - 1 - p_buf_len - 1 - NumCyclesPower_len - 1 - salt_len_len - 1 - salt_buf_len - 1 - iv_len_len - 1 - iv_buf_len - 1 - crc_buf_len - 1 - data_len_len - 1 - unpack_size_len - 1;
+  u32 data_buf_len = input_len - 1 - 2 - 1 - p_buf_len - 1 - NumCyclesPower_len - 1 - salt_len_len - 1 - salt_buf_len - 1 - iv_len_len - 1 - iv_buf_len - 1 - crc_buf_len - 1 - data_len_len - 1 - unpack_size_len - 1;
 
   const uint iter         = atoi (NumCyclesPower_pos);
   const uint crc          = atoi (crc_buf_pos);
@@ -17924,10 +18034,10 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * store data
    */
 
-  seven_zip->iv_buf[0] = hex_to_uint (&iv_buf_pos[ 0]);
-  seven_zip->iv_buf[1] = hex_to_uint (&iv_buf_pos[ 8]);
-  seven_zip->iv_buf[2] = hex_to_uint (&iv_buf_pos[16]);
-  seven_zip->iv_buf[3] = hex_to_uint (&iv_buf_pos[24]);
+  seven_zip->iv_buf[0] = hex_to_u32 ((const u8 *) &iv_buf_pos[ 0]);
+  seven_zip->iv_buf[1] = hex_to_u32 ((const u8 *) &iv_buf_pos[ 8]);
+  seven_zip->iv_buf[2] = hex_to_u32 ((const u8 *) &iv_buf_pos[16]);
+  seven_zip->iv_buf[3] = hex_to_u32 ((const u8 *) &iv_buf_pos[24]);
 
   seven_zip->iv_len = iv_len;
 
@@ -17939,7 +18049,7 @@ int seven_zip_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   for (uint i = 0, j = 0; j < data_buf_len; i += 1, j += 8)
   {
-    seven_zip->data_buf[i] = hex_to_uint (&data_buf_pos[j]);
+    seven_zip->data_buf[i] = hex_to_u32 ((const u8 *) &data_buf_pos[j]);
 
     seven_zip->data_buf[i] = byte_swap_32 (seven_zip->data_buf[i]);
   }
@@ -17977,16 +18087,16 @@ int gost2012sbog_256_parse_hash (char *input_buf, uint input_len, hash_t *hash_b
 {
   if ((input_len < DISPLAY_LEN_MIN_11700) || (input_len > DISPLAY_LEN_MAX_11700)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
-  digest[5] = hex_to_uint (&input_buf[40]);
-  digest[6] = hex_to_uint (&input_buf[48]);
-  digest[7] = hex_to_uint (&input_buf[56]);
+  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]);
 
   digest[0] = byte_swap_32 (digest[0]);
   digest[1] = byte_swap_32 (digest[1]);
@@ -18004,24 +18114,24 @@ int gost2012sbog_512_parse_hash (char *input_buf, uint input_len, hash_t *hash_b
 {
   if ((input_len < DISPLAY_LEN_MIN_11800) || (input_len > DISPLAY_LEN_MAX_11800)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
-
-  digest[ 0] = hex_to_uint (&input_buf[  0]);
-  digest[ 1] = hex_to_uint (&input_buf[  8]);
-  digest[ 2] = hex_to_uint (&input_buf[ 16]);
-  digest[ 3] = hex_to_uint (&input_buf[ 24]);
-  digest[ 4] = hex_to_uint (&input_buf[ 32]);
-  digest[ 5] = hex_to_uint (&input_buf[ 40]);
-  digest[ 6] = hex_to_uint (&input_buf[ 48]);
-  digest[ 7] = hex_to_uint (&input_buf[ 56]);
-  digest[ 8] = hex_to_uint (&input_buf[ 64]);
-  digest[ 9] = hex_to_uint (&input_buf[ 72]);
-  digest[10] = hex_to_uint (&input_buf[ 80]);
-  digest[11] = hex_to_uint (&input_buf[ 88]);
-  digest[12] = hex_to_uint (&input_buf[ 96]);
-  digest[13] = hex_to_uint (&input_buf[104]);
-  digest[14] = hex_to_uint (&input_buf[112]);
-  digest[15] = hex_to_uint (&input_buf[120]);
+  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]);
+  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]);
+  digest[ 8] = hex_to_u32 ((const u8 *) &input_buf[ 64]);
+  digest[ 9] = hex_to_u32 ((const u8 *) &input_buf[ 72]);
+  digest[10] = hex_to_u32 ((const u8 *) &input_buf[ 80]);
+  digest[11] = hex_to_u32 ((const u8 *) &input_buf[ 88]);
+  digest[12] = hex_to_u32 ((const u8 *) &input_buf[ 96]);
+  digest[13] = hex_to_u32 ((const u8 *) &input_buf[104]);
+  digest[14] = hex_to_u32 ((const u8 *) &input_buf[112]);
+  digest[15] = hex_to_u32 ((const u8 *) &input_buf[120]);
 
   digest[ 0] = byte_swap_32 (digest[ 0]);
   digest[ 1] = byte_swap_32 (digest[ 1]);
@@ -18049,7 +18159,7 @@ int pbkdf2_md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_PBKDF2_MD5, input_buf, 4)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -18063,7 +18173,7 @@ int pbkdf2_md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *iter_pos = input_buf + 4;
 
-  uint32_t iter = atoi (iter_pos);
+  u32 iter = atoi (iter_pos);
 
   if (iter <      1) return (PARSER_SALT_ITERATION);
   if (iter > 999999) return (PARSER_SALT_ITERATION);
@@ -18080,13 +18190,13 @@ int pbkdf2_md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_len = hash_pos - salt_pos;
+  u32 salt_len = hash_pos - salt_pos;
 
   if (salt_len > 64) return (PARSER_SALT_LENGTH);
 
   hash_pos++;
 
-  uint32_t hash_b64_len = input_len - (hash_pos - input_buf);
+  u32 hash_b64_len = input_len - (hash_pos - input_buf);
 
   if (hash_b64_len > 88) return (PARSER_HASH_LENGTH);
 
@@ -18106,11 +18216,9 @@ int pbkdf2_md5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // decode hash
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  int hash_len = base64_decode (base64_to_int, hash_pos, hash_b64_len, tmp_buf);
+  int hash_len = base64_decode (base64_to_int, (const u8 *) hash_pos, hash_b64_len, tmp_buf);
 
   if (hash_len < 16) return (PARSER_HASH_LENGTH);
 
@@ -18133,7 +18241,7 @@ int pbkdf2_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_PBKDF2_SHA1, input_buf, 5)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -18147,7 +18255,7 @@ int pbkdf2_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *iter_pos = input_buf + 5;
 
-  uint32_t iter = atoi (iter_pos);
+  u32 iter = atoi (iter_pos);
 
   if (iter <      1) return (PARSER_SALT_ITERATION);
   if (iter > 999999) return (PARSER_SALT_ITERATION);
@@ -18164,13 +18272,13 @@ int pbkdf2_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_len = hash_pos - salt_pos;
+  u32 salt_len = hash_pos - salt_pos;
 
   if (salt_len > 64) return (PARSER_SALT_LENGTH);
 
   hash_pos++;
 
-  uint32_t hash_b64_len = input_len - (hash_pos - input_buf);
+  u32 hash_b64_len = input_len - (hash_pos - input_buf);
 
   if (hash_b64_len > 88) return (PARSER_HASH_LENGTH);
 
@@ -18190,11 +18298,9 @@ int pbkdf2_sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // decode hash
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  int hash_len = base64_decode (base64_to_int, hash_pos, hash_b64_len, tmp_buf);
+  int hash_len = base64_decode (base64_to_int, (const u8 *) hash_pos, hash_b64_len, tmp_buf);
 
   if (hash_len < 16) return (PARSER_HASH_LENGTH);
 
@@ -18222,7 +18328,7 @@ int pbkdf2_sha512_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_PBKDF2_SHA512, input_buf, 7)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint64_t *digest = (uint64_t *) hash_buf->digest;
+  u64 *digest = (u64 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -18236,7 +18342,7 @@ int pbkdf2_sha512_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *iter_pos = input_buf + 7;
 
-  uint32_t iter = atoi (iter_pos);
+  u32 iter = atoi (iter_pos);
 
   if (iter <      1) return (PARSER_SALT_ITERATION);
   if (iter > 999999) return (PARSER_SALT_ITERATION);
@@ -18253,13 +18359,13 @@ int pbkdf2_sha512_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_len = hash_pos - salt_pos;
+  u32 salt_len = hash_pos - salt_pos;
 
   if (salt_len > 64) return (PARSER_SALT_LENGTH);
 
   hash_pos++;
 
-  uint32_t hash_b64_len = input_len - (hash_pos - input_buf);
+  u32 hash_b64_len = input_len - (hash_pos - input_buf);
 
   if (hash_b64_len > 88) return (PARSER_HASH_LENGTH);
 
@@ -18279,11 +18385,9 @@ int pbkdf2_sha512_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // decode hash
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  int hash_len = base64_decode (base64_to_int, hash_pos, hash_b64_len, tmp_buf);
+  int hash_len = base64_decode (base64_to_int, (const u8 *) hash_pos, hash_b64_len, tmp_buf);
 
   if (hash_len < 16) return (PARSER_HASH_LENGTH);
 
@@ -18329,20 +18433,20 @@ int ecryptfs_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_len = hash_pos - salt_pos;
+  u32 salt_len = hash_pos - salt_pos;
 
   if (salt_len != 16) return (PARSER_SALT_LENGTH);
 
   hash_pos++;
 
-  uint32_t hash_len = input_len - 10 - 2 - 2 - salt_len - 1;
+  u32 hash_len = input_len - 10 - 2 - 2 - salt_len - 1;
 
   if (hash_len != 16) return (PARSER_HASH_LENGTH);
 
   // decode hash
 
-  digest[ 0] = hex_to_uint (&hash_pos[0]);
-  digest[ 1] = hex_to_uint (&hash_pos[8]);
+  digest[ 0] = hex_to_u32 ((const u8 *) &hash_pos[0]);
+  digest[ 1] = hex_to_u32 ((const u8 *) &hash_pos[8]);
   digest[ 2] = 0;
   digest[ 3] = 0;
   digest[ 4] = 0;
@@ -18360,8 +18464,8 @@ int ecryptfs_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   // decode salt
 
-  salt->salt_buf[0] = hex_to_uint (&salt_pos[0]);
-  salt->salt_buf[1] = hex_to_uint (&salt_pos[8]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_pos[0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_pos[8]);
 
   salt->salt_iter = ROUNDS_ECRYPTFS;
   salt->salt_len  = 8;
@@ -18381,7 +18485,7 @@ int bsdicrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt_t *salt = hash_buf->salt;
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   // iteration count
 
@@ -18399,11 +18503,9 @@ int bsdicrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = 4;
 
-  char tmp_buf[100];
-
-  memset (tmp_buf, 0, sizeof (tmp_buf));
+  u8 tmp_buf[100] = { 0 };
 
-  base64_decode (itoa64_to_int, input_buf + 9, 11, tmp_buf);
+  base64_decode (itoa64_to_int, (const u8 *) input_buf + 9, 11, tmp_buf);
 
   memcpy (digest, tmp_buf, 8);
 
@@ -18411,8 +18513,8 @@ int bsdicrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   IP (digest[0], digest[1], tt);
 
-  digest[0] = ROTATE_RIGHT (digest[0], 31);
-  digest[1] = ROTATE_RIGHT (digest[1], 31);
+  digest[0] = rotr32 (digest[0], 31);
+  digest[1] = rotr32 (digest[1], 31);
   digest[2] = 0;
   digest[3] = 0;
 
@@ -18425,7 +18527,7 @@ int rar3hp_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_RAR3, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -18439,7 +18541,7 @@ int rar3hp_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (salt_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t type_len = salt_pos - type_pos;
+  u32 type_len = salt_pos - type_pos;
 
   if (type_len != 1) return (PARSER_SALT_LENGTH);
 
@@ -18449,13 +18551,13 @@ int rar3hp_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (crypted_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_len = crypted_pos - salt_pos;
+  u32 salt_len = crypted_pos - salt_pos;
 
   if (salt_len != 16) return (PARSER_SALT_LENGTH);
 
   crypted_pos++;
 
-  uint32_t crypted_len = input_len - 6 - 1 - type_len - 1 - salt_len - 1;
+  u32 crypted_len = input_len - 6 - 1 - type_len - 1 - salt_len - 1;
 
   if (crypted_len != 32) return (PARSER_SALT_LENGTH);
 
@@ -18463,16 +18565,16 @@ int rar3hp_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * copy data
    */
 
-  salt->salt_buf[0] = hex_to_uint (&salt_pos[0]);
-  salt->salt_buf[1] = hex_to_uint (&salt_pos[8]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_pos[0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_pos[8]);
 
   salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]);
   salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]);
 
-  salt->salt_buf[2] = hex_to_uint (&crypted_pos[ 0]);
-  salt->salt_buf[3] = hex_to_uint (&crypted_pos[ 8]);
-  salt->salt_buf[4] = hex_to_uint (&crypted_pos[16]);
-  salt->salt_buf[5] = hex_to_uint (&crypted_pos[24]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &crypted_pos[ 0]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &crypted_pos[ 8]);
+  salt->salt_buf[4] = hex_to_u32 ((const u8 *) &crypted_pos[16]);
+  salt->salt_buf[5] = hex_to_u32 ((const u8 *) &crypted_pos[24]);
 
   salt->salt_len  = 24;
   salt->salt_iter = ROUNDS_RAR3;
@@ -18494,7 +18596,7 @@ int rar5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_RAR5, input_buf, 1 + 4 + 1)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -18510,7 +18612,7 @@ int rar5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (param1_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t param0_len = param1_pos - param0_pos;
+  u32 param0_len = param1_pos - param0_pos;
 
   param1_pos++;
 
@@ -18518,7 +18620,7 @@ int rar5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (param2_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t param1_len = param2_pos - param1_pos;
+  u32 param1_len = param2_pos - param1_pos;
 
   param2_pos++;
 
@@ -18526,7 +18628,7 @@ int rar5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (param3_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t param2_len = param3_pos - param2_pos;
+  u32 param2_len = param3_pos - param2_pos;
 
   param3_pos++;
 
@@ -18534,7 +18636,7 @@ int rar5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (param4_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t param3_len = param4_pos - param3_pos;
+  u32 param3_len = param4_pos - param3_pos;
 
   param4_pos++;
 
@@ -18542,11 +18644,11 @@ int rar5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (param5_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t param4_len = param5_pos - param4_pos;
+  u32 param4_len = param5_pos - param4_pos;
 
   param5_pos++;
 
-  uint32_t param5_len = input_len - 1 - 4 - 1 - param0_len - 1 - param1_len - 1 - param2_len - 1 - param3_len - 1 - param4_len - 1;
+  u32 param5_len = input_len - 1 - 4 - 1 - param0_len - 1 - param1_len - 1 - param2_len - 1 - param3_len - 1 - param4_len - 1;
 
   char *salt_buf = param1_pos;
   char *iv       = param3_pos;
@@ -18572,15 +18674,15 @@ int rar5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * store data
    */
 
-  salt->salt_buf[0] = hex_to_uint (&salt_buf[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&salt_buf[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&salt_buf[16]);
-  salt->salt_buf[3] = hex_to_uint (&salt_buf[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_buf[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_buf[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &salt_buf[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &salt_buf[24]);
 
-  rar5->iv[0] = hex_to_uint (&iv[ 0]);
-  rar5->iv[1] = hex_to_uint (&iv[ 8]);
-  rar5->iv[2] = hex_to_uint (&iv[16]);
-  rar5->iv[3] = hex_to_uint (&iv[24]);
+  rar5->iv[0] = hex_to_u32 ((const u8 *) &iv[ 0]);
+  rar5->iv[1] = hex_to_u32 ((const u8 *) &iv[ 8]);
+  rar5->iv[2] = hex_to_u32 ((const u8 *) &iv[16]);
+  rar5->iv[3] = hex_to_u32 ((const u8 *) &iv[24]);
 
   salt->salt_len = 16;
 
@@ -18592,30 +18694,126 @@ int rar5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * digest buf
    */
 
-  digest[0] = hex_to_uint (&pswcheck[ 0]);
-  digest[1] = hex_to_uint (&pswcheck[ 8]);
+  digest[0] = hex_to_u32 ((const u8 *) &pswcheck[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &pswcheck[ 8]);
   digest[2] = 0;
   digest[3] = 0;
 
   return (PARSER_OK);
 }
 
+int krb5tgs_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  if ((input_len < DISPLAY_LEN_MIN_13100) || (input_len > DISPLAY_LEN_MAX_13100)) return (PARSER_GLOBAL_LENGTH);
+
+  if (memcmp (SIGNATURE_KRB5TGS, input_buf, 11)) return (PARSER_SIGNATURE_UNMATCHED);
+
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  krb5tgs_t *krb5tgs = (krb5tgs_t *) hash_buf->esalt;
+
+  /**
+   * parse line
+   */
+
+  /* Skip '$' */
+  char *account_pos = input_buf + 11 + 1; 
+  
+  char *data_pos;
+
+  uint data_len;
+
+  if (account_pos[0] == '*')
+  {
+    account_pos++;
+
+    data_pos = strchr (account_pos, '*');
+
+    /* Skip '*' */
+    data_pos++;
+
+    if (data_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+    uint account_len = data_pos - account_pos + 1;
+
+    if (account_len >= 512) return (PARSER_SALT_LENGTH);
+
+    /* Skip '$' */
+    data_pos++;
+
+    data_len = input_len - 11 - 1 - account_len - 2;
+
+    memcpy (krb5tgs->account_info, account_pos - 1, account_len);
+  }
+  else
+  {
+    /* assume $krb5tgs$23$checksum$edata2 */
+    data_pos = account_pos;
+
+    memcpy (krb5tgs->account_info, "**", 3);
+
+    data_len = input_len - 11 - 1 - 1;
+  }
+
+  if (data_len < ((16 + 32) * 2)) return (PARSER_SALT_LENGTH);
+
+  char *checksum_ptr = (char *) krb5tgs->checksum;
+
+  for (uint i = 0; i < 16 * 2; i += 2)
+  {
+    const char p0 = data_pos[i + 0];
+    const char p1 = data_pos[i + 1];
+
+    *checksum_ptr++ = hex_convert (p1) << 0
+                     | hex_convert (p0) << 4;
+  }
+
+  char *edata_ptr = (char *) krb5tgs->edata2;
+
+  /* skip '$' */
+  for (uint i = 16 * 2 + 1; i < input_len; i += 2)
+  {
+    const char p0 = data_pos[i + 0];
+    const char p1 = data_pos[i + 1];
+    *edata_ptr++ = hex_convert (p1) << 0
+                    | hex_convert (p0) << 4;
+  }
+  
+  krb5tgs->edata2_len = strlen(edata_ptr - input_len)/(2 * 4);
+
+  salt->salt_buf[0] = krb5tgs->checksum[0];
+  salt->salt_buf[1] = krb5tgs->checksum[1];
+  salt->salt_buf[2] = krb5tgs->checksum[2];
+  salt->salt_buf[3] = krb5tgs->checksum[3];
+  
+  salt->salt_len = 32;
+
+  digest[0] = krb5tgs->checksum[0];
+  digest[1] = krb5tgs->checksum[1];
+  digest[2] = krb5tgs->checksum[2];
+  digest[3] = krb5tgs->checksum[3];
+
+  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);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_uint (&input_buf[ 0]);
-  digest[1] = hex_to_uint (&input_buf[ 8]);
-  digest[2] = hex_to_uint (&input_buf[16]);
-  digest[3] = hex_to_uint (&input_buf[24]);
-  digest[4] = hex_to_uint (&input_buf[32]);
-  digest[5] = hex_to_uint (&input_buf[40]);
-  digest[6] = hex_to_uint (&input_buf[48]);
-  digest[7] = hex_to_uint (&input_buf[56]);
+  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);
 
@@ -18635,7 +18833,7 @@ int cf10_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * we can precompute the first sha256 transform
    */
 
-  uint w[16];
+  uint w[16] = { 0 };
 
   w[ 0] = byte_swap_32 (salt->salt_buf[ 0]);
   w[ 1] = byte_swap_32 (salt->salt_buf[ 1]);
@@ -18654,16 +18852,7 @@ int cf10_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   w[14] = byte_swap_32 (salt->salt_buf[14]);
   w[15] = byte_swap_32 (salt->salt_buf[15]);
 
-  uint pc256[8];
-
-  pc256[0] = SHA256M_A;
-  pc256[1] = SHA256M_B;
-  pc256[2] = SHA256M_C;
-  pc256[3] = SHA256M_D;
-  pc256[4] = SHA256M_E;
-  pc256[5] = SHA256M_F;
-  pc256[6] = SHA256M_G;
-  pc256[7] = SHA256M_H;
+  uint pc256[8] = { SHA256M_A, SHA256M_B, SHA256M_C, SHA256M_D, SHA256M_E, SHA256M_F, SHA256M_G, SHA256M_H };
 
   sha256_64 (w, pc256);
 
@@ -18694,7 +18883,7 @@ int mywallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_MYWALLET, input_buf, 12)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -18708,20 +18897,20 @@ int mywallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (data_buf_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t data_len_len = data_buf_pos - data_len_pos;
+  u32 data_len_len = data_buf_pos - data_len_pos;
 
   if (data_len_len < 1) return (PARSER_SALT_LENGTH);
   if (data_len_len > 5) return (PARSER_SALT_LENGTH);
 
   data_buf_pos++;
 
-  uint32_t data_buf_len = input_len - 1 - 10 - 1 - data_len_len - 1;
+  u32 data_buf_len = input_len - 1 - 10 - 1 - data_len_len - 1;
 
   if (data_buf_len < 64) return (PARSER_HASH_LENGTH);
 
   if (data_buf_len % 16) return (PARSER_HASH_LENGTH);
 
-  uint32_t data_len = atoi (data_len_pos);
+  u32 data_len = atoi (data_len_pos);
 
   if ((data_len * 2) != data_buf_len) return (PARSER_HASH_LENGTH);
 
@@ -18731,17 +18920,17 @@ int mywallet_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *salt_pos = data_buf_pos;
 
-  salt->salt_buf[0] = hex_to_uint (&salt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&salt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&salt_pos[16]);
-  salt->salt_buf[3] = hex_to_uint (&salt_pos[24]);
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &salt_pos[16]);
+  salt->salt_buf[3] = hex_to_u32 ((const u8 *) &salt_pos[24]);
 
   // this is actually the CT, which is also the hash later (if matched)
 
-  salt->salt_buf[4] = hex_to_uint (&salt_pos[32]);
-  salt->salt_buf[5] = hex_to_uint (&salt_pos[40]);
-  salt->salt_buf[6] = hex_to_uint (&salt_pos[48]);
-  salt->salt_buf[7] = hex_to_uint (&salt_pos[56]);
+  salt->salt_buf[4] = hex_to_u32 ((const u8 *) &salt_pos[32]);
+  salt->salt_buf[5] = hex_to_u32 ((const u8 *) &salt_pos[40]);
+  salt->salt_buf[6] = hex_to_u32 ((const u8 *) &salt_pos[48]);
+  salt->salt_buf[7] = hex_to_u32 ((const u8 *) &salt_pos[56]);
 
   salt->salt_len = 32; // note we need to fix this to 16 in kernel
 
@@ -18765,7 +18954,7 @@ int ms_drsr_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (SIGNATURE_MS_DRSR, input_buf, 11)) return (PARSER_SIGNATURE_UNMATCHED);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -18779,7 +18968,7 @@ int ms_drsr_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (iter_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t salt_len = iter_pos - salt_pos;
+  u32 salt_len = iter_pos - salt_pos;
 
   if (salt_len != 20) return (PARSER_SALT_LENGTH);
 
@@ -18789,13 +18978,13 @@ int ms_drsr_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
-  uint32_t iter_len = hash_pos - iter_pos;
+  u32 iter_len = hash_pos - iter_pos;
 
   if (iter_len > 5) return (PARSER_SALT_LENGTH);
 
   hash_pos++;
 
-  uint32_t hash_len = input_len - 11 - 1 - salt_len - 1 - iter_len - 1;
+  u32 hash_len = input_len - 11 - 1 - salt_len - 1 - iter_len - 1;
 
   if (hash_len != 64) return (PARSER_HASH_LENGTH);
 
@@ -18803,9 +18992,9 @@ int ms_drsr_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * salt
    */
 
-  salt->salt_buf[0] = hex_to_uint (&salt_pos[ 0]);
-  salt->salt_buf[1] = hex_to_uint (&salt_pos[ 8]);
-  salt->salt_buf[2] = hex_to_uint (&salt_pos[16]) & 0xffff0000;
+  salt->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_pos[ 0]);
+  salt->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_pos[ 8]);
+  salt->salt_buf[2] = hex_to_u32 ((const u8 *) &salt_pos[16]) & 0xffff0000;
   salt->salt_buf[3] = 0x00018000;
 
   salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]);
@@ -18821,14 +19010,14 @@ int ms_drsr_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
    * digest buf
    */
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
-  digest[5] = hex_to_uint (&hash_pos[40]);
-  digest[6] = hex_to_uint (&hash_pos[48]);
-  digest[7] = hex_to_uint (&hash_pos[56]);
+  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[5] = hex_to_u32 ((const u8 *) &hash_pos[40]);
+  digest[6] = hex_to_u32 ((const u8 *) &hash_pos[48]);
+  digest[7] = hex_to_u32 ((const u8 *) &hash_pos[56]);
 
   return (PARSER_OK);
 }
@@ -18837,7 +19026,7 @@ int androidfde_samsung_parse_hash (char *input_buf, uint input_len, hash_t *hash
 {
   if ((input_len < DISPLAY_LEN_MIN_12900) || (input_len > DISPLAY_LEN_MAX_12900)) return (PARSER_GLOBAL_LENGTH);
 
-  uint32_t *digest = (uint32_t *) hash_buf->digest;
+  u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
@@ -18853,20 +19042,20 @@ int androidfde_samsung_parse_hash (char *input_buf, uint input_len, hash_t *hash
    * salt
    */
 
-  salt->salt_buf[ 0] = hex_to_uint (&salt1_pos[ 0]);
-  salt->salt_buf[ 1] = hex_to_uint (&salt1_pos[ 8]);
-  salt->salt_buf[ 2] = hex_to_uint (&salt1_pos[16]);
-  salt->salt_buf[ 3] = hex_to_uint (&salt1_pos[24]);
+  salt->salt_buf[ 0] = hex_to_u32 ((const u8 *) &salt1_pos[ 0]);
+  salt->salt_buf[ 1] = hex_to_u32 ((const u8 *) &salt1_pos[ 8]);
+  salt->salt_buf[ 2] = hex_to_u32 ((const u8 *) &salt1_pos[16]);
+  salt->salt_buf[ 3] = hex_to_u32 ((const u8 *) &salt1_pos[24]);
 
-  salt->salt_buf[ 4] = hex_to_uint (&salt2_pos[ 0]);
-  salt->salt_buf[ 5] = hex_to_uint (&salt2_pos[ 8]);
-  salt->salt_buf[ 6] = hex_to_uint (&salt2_pos[16]);
-  salt->salt_buf[ 7] = hex_to_uint (&salt2_pos[24]);
+  salt->salt_buf[ 4] = hex_to_u32 ((const u8 *) &salt2_pos[ 0]);
+  salt->salt_buf[ 5] = hex_to_u32 ((const u8 *) &salt2_pos[ 8]);
+  salt->salt_buf[ 6] = hex_to_u32 ((const u8 *) &salt2_pos[16]);
+  salt->salt_buf[ 7] = hex_to_u32 ((const u8 *) &salt2_pos[24]);
 
-  salt->salt_buf[ 8] = hex_to_uint (&salt2_pos[32]);
-  salt->salt_buf[ 9] = hex_to_uint (&salt2_pos[40]);
-  salt->salt_buf[10] = hex_to_uint (&salt2_pos[48]);
-  salt->salt_buf[11] = hex_to_uint (&salt2_pos[56]);
+  salt->salt_buf[ 8] = hex_to_u32 ((const u8 *) &salt2_pos[32]);
+  salt->salt_buf[ 9] = hex_to_u32 ((const u8 *) &salt2_pos[40]);
+  salt->salt_buf[10] = hex_to_u32 ((const u8 *) &salt2_pos[48]);
+  salt->salt_buf[11] = hex_to_u32 ((const u8 *) &salt2_pos[56]);
 
   salt->salt_len = 48;
 
@@ -18876,14 +19065,14 @@ int androidfde_samsung_parse_hash (char *input_buf, uint input_len, hash_t *hash
    * digest buf
    */
 
-  digest[0] = hex_to_uint (&hash_pos[ 0]);
-  digest[1] = hex_to_uint (&hash_pos[ 8]);
-  digest[2] = hex_to_uint (&hash_pos[16]);
-  digest[3] = hex_to_uint (&hash_pos[24]);
-  digest[4] = hex_to_uint (&hash_pos[32]);
-  digest[5] = hex_to_uint (&hash_pos[40]);
-  digest[6] = hex_to_uint (&hash_pos[48]);
-  digest[7] = hex_to_uint (&hash_pos[56]);
+  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[5] = hex_to_u32 ((const u8 *) &hash_pos[40]);
+  digest[6] = hex_to_u32 ((const u8 *) &hash_pos[48]);
+  digest[7] = hex_to_u32 ((const u8 *) &hash_pos[56]);
 
   return (PARSER_OK);
 }
@@ -18903,7 +19092,7 @@ BOOL WINAPI sigHandler_default (DWORD sig)
       /*
        * special case see: https://stackoverflow.com/questions/3640633/c-setconsolectrlhandler-routine-issue/5610042#5610042
        * if the user interacts w/ the user-interface (GUI/cmd), we need to do the finalization job within this signal handler
-       * function otherwise it is to late (e.g. after returning from this function)
+       * function otherwise it is too late (e.g. after returning from this function)
        */
 
       myabort ();
@@ -19119,27 +19308,27 @@ void *thread_keypress (void *p)
  * rules common
  */
 
-bool class_num (char c)
+bool class_num (const u8 c)
 {
   return ((c >= '0') && (c <= '9'));
 }
 
-bool class_lower (char c)
+bool class_lower (const u8 c)
 {
   return ((c >= 'a') && (c <= 'z'));
 }
 
-bool class_upper (char c)
+bool class_upper (const u8 c)
 {
   return ((c >= 'A') && (c <= 'Z'));
 }
 
-bool class_alpha (char c)
+bool class_alpha (const u8 c)
 {
   return (class_lower (c) || class_upper (c));
 }
 
-char conv_ctoi (char c)
+int conv_ctoi (const u8 c)
 {
   if (class_num (c))
   {
@@ -19147,13 +19336,13 @@ char conv_ctoi (char c)
   }
   else if (class_upper (c))
   {
-    return c - 'A' + (char) 10;
+    return c - 'A' + 10;
   }
 
-  return (char) (-1);
+  return -1;
 }
 
-char conv_itoc (char c)
+int conv_itoc (const u8 c)
 {
   if (c < 10)
   {
@@ -19161,10 +19350,10 @@ char conv_itoc (char c)
   }
   else if (c < 37)
   {
-    return c + 'A' - (char) 10;
+    return c + 'A' - 10;
   }
 
-  return (char) (-1);
+  return -1;
 }
 
 /**
@@ -19916,7 +20105,7 @@ int mangle_dupeblock_prepend (char arr[BLOCK_SIZE], int arr_len, int ulen)
 
   if ((arr_len + ulen) >= BLOCK_SIZE) return (arr_len);
 
-  char cs[100];
+  char cs[100] = { 0 };
 
   memcpy (cs, arr, ulen);
 
@@ -20005,7 +20194,7 @@ int mangle_switch_at (char arr[BLOCK_SIZE], int arr_len, int upos, int upos2)
   return (arr_len);
 }
 
-int mangle_chr_shiftl (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
+int mangle_chr_shiftl (char arr[BLOCK_SIZE], int arr_len, int upos)
 {
   if (upos >= arr_len) return (arr_len);
 
@@ -20014,7 +20203,7 @@ int mangle_chr_shiftl (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
   return (arr_len);
 }
 
-int mangle_chr_shiftr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
+int mangle_chr_shiftr (char arr[BLOCK_SIZE], int arr_len, int upos)
 {
   if (upos >= arr_len) return (arr_len);
 
@@ -20023,7 +20212,7 @@ int mangle_chr_shiftr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
   return (arr_len);
 }
 
-int mangle_chr_incr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
+int mangle_chr_incr (char arr[BLOCK_SIZE], int arr_len, int upos)
 {
   if (upos >= arr_len) return (arr_len);
 
@@ -20032,7 +20221,7 @@ int mangle_chr_incr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
   return (arr_len);
 }
 
-int mangle_chr_decr (uint8_t arr[BLOCK_SIZE], int arr_len, int upos)
+int mangle_chr_decr (char arr[BLOCK_SIZE], int arr_len, int upos)
 {
   if (upos >= arr_len) return (arr_len);
 
@@ -20071,20 +20260,20 @@ int mangle_title (char arr[BLOCK_SIZE], int arr_len)
   return (arr_len);
 }
 
-int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], uint32_t rp_gen_func_min, uint32_t rp_gen_func_max)
+int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max)
 {
-  uint32_t rp_gen_num = get_random_num (rp_gen_func_min, rp_gen_func_max);
+  u32 rp_gen_num = get_random_num (rp_gen_func_min, rp_gen_func_max);
 
-  uint32_t j;
+  u32 j;
 
-  uint32_t rule_pos = 0;
+  u32 rule_pos = 0;
 
   for (j = 0; j < rp_gen_num; j++)
   {
-    uint32_t r  = 0;
-    uint32_t p1 = 0;
-    uint32_t p2 = 0;
-    uint32_t p3 = 0;
+    u32 r  = 0;
+    u32 p1 = 0;
+    u32 p2 = 0;
+    u32 p3 = 0;
 
     switch ((char) get_random_num (0, 9))
     {
@@ -20174,13 +20363,13 @@ int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], uint32_t rp_gen_func_mi
 
 int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE])
 {
-  char mem[BLOCK_SIZE];
+  char mem[BLOCK_SIZE] = { 0 };
 
   if (in == NULL) return (RULE_RC_REJECT_ERROR);
 
   if (out == NULL) return (RULE_RC_REJECT_ERROR);
 
-  if (in_len < 1) return (RULE_RC_REJECT_ERROR);
+  if (in_len < 1 || in_len > BLOCK_SIZE) return (RULE_RC_REJECT_ERROR);
 
   if (rule_len < 1) return (RULE_RC_REJECT_ERROR);
 
@@ -20193,7 +20382,7 @@ int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len,
 
   for (rule_pos = 0; rule_pos < rule_len; rule_pos++)
   {
-    int upos; int upos2;
+    int upos, upos2;
     int ulen;
 
     switch (rule[rule_pos])
@@ -20380,25 +20569,25 @@ int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len,
       case RULE_OP_MANGLE_CHR_SHIFTL:
         NEXT_RULEPOS (rule_pos);
         NEXT_RPTOI (rule, rule_pos, upos);
-        mangle_chr_shiftl ((uint8_t *) out, out_len, upos);
+        mangle_chr_shiftl (out, out_len, upos);
         break;
 
       case RULE_OP_MANGLE_CHR_SHIFTR:
         NEXT_RULEPOS (rule_pos);
         NEXT_RPTOI (rule, rule_pos, upos);
-        mangle_chr_shiftr ((uint8_t *) out, out_len, upos);
+        mangle_chr_shiftr (out, out_len, upos);
         break;
 
       case RULE_OP_MANGLE_CHR_INCR:
         NEXT_RULEPOS (rule_pos);
         NEXT_RPTOI (rule, rule_pos, upos);
-        mangle_chr_incr ((uint8_t *) out, out_len, upos);
+        mangle_chr_incr (out, out_len, upos);
         break;
 
       case RULE_OP_MANGLE_CHR_DECR:
         NEXT_RULEPOS (rule_pos);
         NEXT_RPTOI (rule, rule_pos, upos);
-        mangle_chr_decr ((uint8_t *) out, out_len, upos);
+        mangle_chr_decr (out, out_len, upos);
         break;
 
       case RULE_OP_MANGLE_REPLACE_NP1: