From 6dca0fe857e3f2041d79e04708e8fac4bb34e65b Mon Sep 17 00:00:00 2001
From: magnum <magnum>
Date: Wed, 23 Nov 2011 12:38:05 +0100
Subject: [PATCH 5/6] Implement new binary_hash/get_hash sizes for a bunch of
 formats

---
 src/IPB2_fmt_plug.c        |   28 ++++++++++++++++++++++++-
 src/NT_fmt_plug.c          |   46 ++++++++++++++++++++++++++++++++++++++++++-
 src/SybaseASE_fmt.c        |   28 ++++++++++++++++++++++++-
 src/XSHA512_fmt.c          |   28 ++++++++++++++++++++++++-
 src/XSHA_fmt_plug.c        |   28 ++++++++++++++++++++++++-
 src/hmailserver_fmt.c      |   28 ++++++++++++++++++++++++-
 src/md4_gen_fmt_plug.c     |   28 ++++++++++++++++++++++++-
 src/rawMD4_fmt_plug.c      |   40 ++++++++++++++++++++++++++++++++++++-
 src/rawSHA1_fmt_plug.c     |   26 ++++++++++++++++++++++-
 src/rawSHA224_fmt.c        |   28 ++++++++++++++++++++++++-
 src/rawSHA256_fmt.c        |   28 ++++++++++++++++++++++++-
 src/rawSHA384_fmt.c        |   28 ++++++++++++++++++++++++-
 src/rawSHA512_fmt.c        |   28 ++++++++++++++++++++++++-
 src/salted_sha1_fmt_plug.c |   26 ++++++++++++++++++++++-
 src/sapB_fmt_plug.c        |   28 ++++++++++++++++++++++++-
 src/sapG_fmt_plug.c        |   28 ++++++++++++++++++++++++-
 src/sha1_gen_fmt_plug.c    |   28 ++++++++++++++++++++++++-
 17 files changed, 468 insertions(+), 34 deletions(-)

diff --git a/src/IPB2_fmt_plug.c b/src/IPB2_fmt_plug.c
index 492f473..f6b34b0 100644
--- a/src/IPB2_fmt_plug.c
+++ b/src/IPB2_fmt_plug.c
@@ -233,6 +233,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32*)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return *output & 0xF;
@@ -258,6 +268,16 @@ static int get_hash_4(int index)
 	return *output & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return *output & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return *output & 0x7FFFFFF;
+}
+
 static int salt_hash(void *salt)
 {
 	return *(ARCH_WORD_32*)salt & (SALT_HASH_SIZE - 1);
@@ -290,7 +310,9 @@ struct fmt_main fmt_IPB2 = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		salt_hash,
 		ipb2_set_salt,
@@ -303,7 +325,9 @@ struct fmt_main fmt_IPB2 = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		ipb2_cmp_all,
 		ipb2_cmp_all,
diff --git a/src/NT_fmt_plug.c b/src/NT_fmt_plug.c
index 411d6c3..4777f29 100644
--- a/src/NT_fmt_plug.c
+++ b/src/NT_fmt_plug.c
@@ -411,6 +411,16 @@ static int binary_hash_4(void *binary)
 	return ((unsigned int *)binary)[1] & 0x0FFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return ((unsigned int *)binary)[1] & 0x0FFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return ((unsigned int *)binary)[1] & 0x07FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 #if defined(NT_X86_64)
@@ -481,6 +491,34 @@ static int get_hash_4(int index)
 #endif
 }
 
+static int get_hash_5(int index)
+{
+#if defined(NT_X86_64)
+	return output8x[32*(index>>3)+8+index%8] & 0x0FFFFFF;
+#elif defined(NT_SSE2)
+	if(index<NT_NUM_KEYS4)
+		return output4x[16*(index>>2)+4+index%4] & 0x0FFFFFF;
+	else
+		return output1x[(index-NT_NUM_KEYS4)*4+1] & 0x0FFFFFF;
+#else
+	return output1x[(index<<2)+1] & 0x0FFFFFF;
+#endif
+}
+
+static int get_hash_6(int index)
+{
+#if defined(NT_X86_64)
+	return output8x[32*(index>>3)+8+index%8] & 0x07FFFFFF;
+#elif defined(NT_SSE2)
+	if(index<NT_NUM_KEYS4)
+		return output4x[16*(index>>2)+4+index%4] & 0x07FFFFFF;
+	else
+		return output1x[(index-NT_NUM_KEYS4)*4+1] & 0x07FFFFFF;
+#else
+	return output1x[(index<<2)+1] & 0x07FFFFFF;
+#endif
+}
+
 static int cmp_all(void *binary, int count)
 {
 	unsigned int i=0;
@@ -921,7 +959,9 @@ struct fmt_main fmt_NT = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		fmt_default_salt_hash,
 		fmt_default_set_salt,
@@ -934,7 +974,9 @@ struct fmt_main fmt_NT = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_one,
diff --git a/src/SybaseASE_fmt.c b/src/SybaseASE_fmt.c
index bfd0620..0b1ec60 100644
--- a/src/SybaseASE_fmt.c
+++ b/src/SybaseASE_fmt.c
@@ -139,6 +139,16 @@ static int binary_hash_4(void *binary)
     return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+    return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+    return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
     return crypt_out[index][0] & 0xF;
@@ -164,6 +174,16 @@ static int get_hash_4(int index)
     return crypt_out[index][0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+    return crypt_out[index][0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+    return crypt_out[index][0] & 0x7FFFFFF;
+}
+
 static void set_salt(void *salt)
 {
     saved_salt = salt;
@@ -265,7 +285,9 @@ struct fmt_main fmt_SybaseASE = {
             binary_hash_1,
             binary_hash_2,
             binary_hash_3,
-            binary_hash_4
+            binary_hash_4,
+            binary_hash_5,
+            binary_hash_6
         },
         salt_hash,
         set_salt,
@@ -278,7 +300,9 @@ struct fmt_main fmt_SybaseASE = {
             get_hash_1,
             get_hash_2,
             get_hash_3,
-            get_hash_4
+            get_hash_4,
+            get_hash_5,
+            get_hash_6
         },
         cmp_all,
         cmp_one,
diff --git a/src/XSHA512_fmt.c b/src/XSHA512_fmt.c
index 2993a4a..f48e015 100644
--- a/src/XSHA512_fmt.c
+++ b/src/XSHA512_fmt.c
@@ -155,6 +155,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return crypt_out[index][0] & 0xF;
@@ -180,6 +190,16 @@ static int get_hash_4(int index)
 	return crypt_out[index][0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return crypt_out[index][0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return crypt_out[index][0] & 0x7FFFFFF;
+}
+
 static int salt_hash(void *salt)
 {
 	return *(ARCH_WORD_32 *)salt & (SALT_HASH_SIZE - 1);
@@ -286,7 +306,9 @@ struct fmt_main fmt_XSHA512 = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		salt_hash,
 		set_salt,
@@ -299,7 +321,9 @@ struct fmt_main fmt_XSHA512 = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_one,
diff --git a/src/XSHA_fmt_plug.c b/src/XSHA_fmt_plug.c
index de0ff66..0a61a2a 100644
--- a/src/XSHA_fmt_plug.c
+++ b/src/XSHA_fmt_plug.c
@@ -116,6 +116,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return crypt_out[index][0] & 0xF;
@@ -141,6 +151,16 @@ static int get_hash_4(int index)
 	return crypt_out[index][0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return crypt_out[index][0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return crypt_out[index][0] & 0x7FFFFFF;
+}
+
 static int salt_hash(void *salt)
 {
 	return *(ARCH_WORD_32 *)salt & (SALT_HASH_SIZE - 1);
@@ -234,7 +254,9 @@ struct fmt_main fmt_XSHA = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		salt_hash,
 		set_salt,
@@ -247,7 +269,9 @@ struct fmt_main fmt_XSHA = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_one,
diff --git a/src/hmailserver_fmt.c b/src/hmailserver_fmt.c
index cb117cb..522de9c 100644
--- a/src/hmailserver_fmt.c
+++ b/src/hmailserver_fmt.c
@@ -136,6 +136,16 @@ static int binary_hash_4(void *binary)
     return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+    return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+    return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
     return crypt_out[0] & 0xF;
@@ -161,6 +171,16 @@ static int get_hash_4(int index)
     return crypt_out[0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+    return crypt_out[0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+    return crypt_out[0] & 0x7FFFFFF;
+}
+
 static int salt_hash(void *salt)
 {
 	return (((ARCH_WORD_32)(ARCH_INDEX(((unsigned char *)salt)[0])-' ')) +
@@ -232,7 +252,9 @@ struct fmt_main fmt_hmailserver = {
             binary_hash_1,
             binary_hash_2,
             binary_hash_3,
-            binary_hash_4
+            binary_hash_4,
+            binary_hash_5,
+            binary_hash_6
         },
         salt_hash,
         set_salt,
@@ -245,7 +267,9 @@ struct fmt_main fmt_hmailserver = {
             get_hash_1,
             get_hash_2,
             get_hash_3,
-            get_hash_4
+            get_hash_4,
+            get_hash_5,
+            get_hash_6
         },
         cmp_all,
         cmp_all,
diff --git a/src/md4_gen_fmt_plug.c b/src/md4_gen_fmt_plug.c
index 9a374ba..3093cab 100644
--- a/src/md4_gen_fmt_plug.c
+++ b/src/md4_gen_fmt_plug.c
@@ -118,6 +118,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return crypt_out[0] & 0xF;
@@ -143,6 +153,16 @@ static int get_hash_4(int index)
 	return crypt_out[0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return crypt_out[0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return crypt_out[0] & 0x7FFFFFF;
+}
+
 static int salt_hash(void *salt)
 {
 	unsigned int hash = 0;
@@ -231,7 +251,9 @@ struct fmt_main fmt_md4_gen = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		salt_hash,
 		set_salt,
@@ -244,7 +266,9 @@ struct fmt_main fmt_md4_gen = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_all,
diff --git a/src/rawMD4_fmt_plug.c b/src/rawMD4_fmt_plug.c
index d14e489..4a7a268 100644
--- a/src/rawMD4_fmt_plug.c
+++ b/src/rawMD4_fmt_plug.c
@@ -139,6 +139,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 #ifdef MD4_SSE_PARA
 static int get_hash_0(int index)
 {
@@ -175,6 +185,20 @@ static int get_hash_4(int index)
         y = index/4;
 	return ((unsigned int *)crypt_key)[x+y*MMX_COEF*4] & 0xfffff;
 }
+static int get_hash_5(int index)
+{
+	unsigned int x,y;
+        x = index&3;
+        y = index/4;
+	return ((unsigned int *)crypt_key)[x+y*MMX_COEF*4] & 0xffffff;
+}
+static int get_hash_6(int index)
+{
+	unsigned int x,y;
+        x = index&3;
+        y = index/4;
+	return ((unsigned int *)crypt_key)[x+y*MMX_COEF*4] & 0x7ffffff;
+}
 #else
 static int get_hash_0(int index)
 {
@@ -200,6 +224,14 @@ static int get_hash_4(int index)
 {
 	return crypt_out[0] & 0xFFFFF;
 }
+static int get_hash_5(int index)
+{
+	return crypt_out[0] & 0xFFFFFF;
+}
+static int get_hash_6(int index)
+{
+	return crypt_out[0] & 0x7FFFFFF;
+}
 #endif
 
 static void set_key(char *key, int index)
@@ -319,7 +351,9 @@ struct fmt_main fmt_rawMD4 = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		fmt_default_salt_hash,
 		fmt_default_set_salt,
@@ -332,7 +366,9 @@ struct fmt_main fmt_rawMD4 = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_one,
diff --git a/src/rawSHA1_fmt_plug.c b/src/rawSHA1_fmt_plug.c
index 950f2ba..82c4a4d 100644
--- a/src/rawSHA1_fmt_plug.c
+++ b/src/rawSHA1_fmt_plug.c
@@ -300,6 +300,8 @@ static int binary_hash_1(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0
 static int binary_hash_2(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0xfff; }
 static int binary_hash_3(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0xffff; }
 static int binary_hash_4(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0xfffff; }
+static int binary_hash_5(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0xffffff; }
+static int binary_hash_6(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0x7ffffff; }
 
 #ifdef MMX_COEF
 static int get_hash_0(int index)
@@ -337,12 +339,28 @@ static int get_hash_4(int index)
         y = index/4;
 	return ((unsigned int *)crypt_key)[x+y*MMX_COEF*5] & 0xfffff;
 }
+static int get_hash_5(int index)
+{
+	unsigned int x,y;
+        x = index&3;
+        y = index/4;
+	return ((unsigned int *)crypt_key)[x+y*MMX_COEF*5] & 0xffffff;
+}
+static int get_hash_6(int index)
+{
+	unsigned int x,y;
+        x = index&3;
+        y = index/4;
+	return ((unsigned int *)crypt_key)[x+y*MMX_COEF*5] & 0x7ffffff;
+}
 #else
 static int get_hash_0(int index) { return ((unsigned int *)crypt_key)[0] & 0xf; }
 static int get_hash_1(int index) { return ((unsigned int *)crypt_key)[0] & 0xff; }
 static int get_hash_2(int index) { return ((unsigned int *)crypt_key)[0] & 0xfff; }
 static int get_hash_3(int index) { return ((unsigned int *)crypt_key)[0] & 0xffff; }
 static int get_hash_4(int index) { return ((unsigned int *)crypt_key)[0] & 0xfffff; }
+static int get_hash_5(int index) { return ((unsigned int *)crypt_key)[0] & 0xffffff; }
+static int get_hash_6(int index) { return ((unsigned int *)crypt_key)[0] & 0x7ffffff; }
 #endif
 
 struct fmt_main fmt_rawSHA1 = {
@@ -371,7 +389,9 @@ struct fmt_main fmt_rawSHA1 = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		fmt_default_salt_hash,
 		fmt_default_set_salt,
@@ -384,7 +404,9 @@ struct fmt_main fmt_rawSHA1 = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		rawsha1_cmp_all,
 		rawsha1_cmp_one,
diff --git a/src/rawSHA224_fmt.c b/src/rawSHA224_fmt.c
index c54cc7f..a17feef 100644
--- a/src/rawSHA224_fmt.c
+++ b/src/rawSHA224_fmt.c
@@ -116,6 +116,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return crypt_out[0] & 0xF;
@@ -141,6 +151,16 @@ static int get_hash_4(int index)
 	return crypt_out[0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return crypt_out[0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return crypt_out[0] & 0x7FFFFFF;
+}
+
 static void set_key(char *key, int index)
 {
 	saved_key_length = strlen(key);
@@ -198,7 +218,9 @@ struct fmt_main fmt_rawSHA224 = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		fmt_default_salt_hash,
 		fmt_default_set_salt,
@@ -211,7 +233,9 @@ struct fmt_main fmt_rawSHA224 = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_all,
diff --git a/src/rawSHA256_fmt.c b/src/rawSHA256_fmt.c
index cb518ba..15ef0f2 100644
--- a/src/rawSHA256_fmt.c
+++ b/src/rawSHA256_fmt.c
@@ -116,6 +116,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return crypt_out[0] & 0xF;
@@ -141,6 +151,16 @@ static int get_hash_4(int index)
 	return crypt_out[0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return crypt_out[0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return crypt_out[0] & 0x7FFFFFF;
+}
+
 static void set_key(char *key, int index)
 {
 	saved_key_length = strlen(key);
@@ -198,7 +218,9 @@ struct fmt_main fmt_rawSHA256 = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		fmt_default_salt_hash,
 		fmt_default_set_salt,
@@ -211,7 +233,9 @@ struct fmt_main fmt_rawSHA256 = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_all,
diff --git a/src/rawSHA384_fmt.c b/src/rawSHA384_fmt.c
index 8867485..cbe7ca1 100644
--- a/src/rawSHA384_fmt.c
+++ b/src/rawSHA384_fmt.c
@@ -120,6 +120,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return crypt_out[0] & 0xF;
@@ -145,6 +155,16 @@ static int get_hash_4(int index)
 	return crypt_out[0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return crypt_out[0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return crypt_out[0] & 0x7FFFFFF;
+}
+
 static void set_key(char *key, int index)
 {
 	saved_key_length = strlen(key);
@@ -202,7 +222,9 @@ struct fmt_main fmt_rawSHA384 = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		fmt_default_salt_hash,
 		fmt_default_set_salt,
@@ -215,7 +237,9 @@ struct fmt_main fmt_rawSHA384 = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_all,
diff --git a/src/rawSHA512_fmt.c b/src/rawSHA512_fmt.c
index ff4f819..be9b2c9 100644
--- a/src/rawSHA512_fmt.c
+++ b/src/rawSHA512_fmt.c
@@ -120,6 +120,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return crypt_out[0] & 0xF;
@@ -145,6 +155,16 @@ static int get_hash_4(int index)
 	return crypt_out[0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return crypt_out[0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return crypt_out[0] & 0x7FFFFFF;
+}
+
 static void set_key(char *key, int index)
 {
 	saved_key_length = strlen(key);
@@ -202,7 +222,9 @@ struct fmt_main fmt_rawSHA512 = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		fmt_default_salt_hash,
 		fmt_default_set_salt,
@@ -215,7 +237,9 @@ struct fmt_main fmt_rawSHA512 = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_all,
diff --git a/src/salted_sha1_fmt_plug.c b/src/salted_sha1_fmt_plug.c
index 50e0851..32ce6bd 100644
--- a/src/salted_sha1_fmt_plug.c
+++ b/src/salted_sha1_fmt_plug.c
@@ -170,6 +170,8 @@ static int binary_hash_1(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0
 static int binary_hash_2(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0xfff; }
 static int binary_hash_3(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0xffff; }
 static int binary_hash_4(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0xfffff; }
+static int binary_hash_5(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0xffffff; }
+static int binary_hash_6(void * binary) { return ((ARCH_WORD_32 *)binary)[0] & 0x7ffffff; }
 
 static void set_key(char *key, int index) {
 #ifdef MMX_COEF
@@ -408,12 +410,28 @@ static int get_hash_4(int index)
         y = index/4;
 	return ((unsigned int *)crypt_key)[x+y*MMX_COEF*5] & 0xfffff;
 }
+static int get_hash_5(int index)
+{
+	unsigned int x,y;
+        x = index&3;
+        y = index/4;
+	return ((unsigned int *)crypt_key)[x+y*MMX_COEF*5] & 0xffffff;
+}
+static int get_hash_6(int index)
+{
+	unsigned int x,y;
+        x = index&3;
+        y = index/4;
+	return ((unsigned int *)crypt_key)[x+y*MMX_COEF*5] & 0x7ffffff;
+}
 #else
 static int get_hash_0(int index) { return ((unsigned int *)crypt_key)[0] & 0xf; }
 static int get_hash_1(int index) { return ((unsigned int *)crypt_key)[0] & 0xff; }
 static int get_hash_2(int index) { return ((unsigned int *)crypt_key)[0] & 0xfff; }
 static int get_hash_3(int index) { return ((unsigned int *)crypt_key)[0] & 0xffff; }
 static int get_hash_4(int index) { return ((unsigned int *)crypt_key)[0] & 0xfffff; }
+static int get_hash_5(int index) { return ((unsigned int *)crypt_key)[0] & 0xffffff; }
+static int get_hash_6(int index) { return ((unsigned int *)crypt_key)[0] & 0x7ffffff; }
 #endif
 
 static int salt_hash(void *salt)
@@ -448,7 +466,9 @@ struct fmt_main fmt_saltedsha = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		salt_hash,
 		set_salt,
@@ -461,7 +481,9 @@ struct fmt_main fmt_saltedsha = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_one,
diff --git a/src/sapB_fmt_plug.c b/src/sapB_fmt_plug.c
index 89c8f4a..a301e00 100644
--- a/src/sapB_fmt_plug.c
+++ b/src/sapB_fmt_plug.c
@@ -285,6 +285,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32*)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32*)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32*)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return *(ARCH_WORD_32*)crypt_key[index] & 0xF;
@@ -310,6 +320,16 @@ static int get_hash_4(int index)
 	return *(ARCH_WORD_32*)crypt_key[index] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return *(ARCH_WORD_32*)crypt_key[index] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return *(ARCH_WORD_32*)crypt_key[index] & 0x7FFFFFF;
+}
+
 // Public domain hash function by DJ Bernstein (salt is a username)
 static int salt_hash(void *salt)
 {
@@ -348,7 +368,9 @@ struct fmt_main fmt_sapB = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		salt_hash,
 		sapbcode_set_salt,
@@ -361,7 +383,9 @@ struct fmt_main fmt_sapB = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		sapbcode_cmp_all,
 		sapbcode_cmp_one,
diff --git a/src/sapG_fmt_plug.c b/src/sapG_fmt_plug.c
index 79b52fb..65220e1 100644
--- a/src/sapG_fmt_plug.c
+++ b/src/sapG_fmt_plug.c
@@ -277,6 +277,16 @@ static int binary_hash_4(void *binary)
 	return ((ARCH_WORD_32 *)binary)[0] & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return ((ARCH_WORD_32 *)binary)[0] & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return ((ARCH_WORD_32 *)binary)[0] & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return crypt_key[index][0] & 0xF;
@@ -302,6 +312,16 @@ static int get_hash_4(int index)
 	return crypt_key[index][0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return crypt_key[index][0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return crypt_key[index][0] & 0x7FFFFFF;
+}
+
 // Public domain hash function by DJ Bernstein (salt is a username)
 static int salt_hash(void *salt)
 {
@@ -349,7 +369,9 @@ struct fmt_main fmt_sapG = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		salt_hash,
 		sapcodvng_set_salt,
@@ -362,7 +384,9 @@ struct fmt_main fmt_sapG = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		sapcodvng_cmp_all,
 		sapcodvng_cmp_one,
diff --git a/src/sha1_gen_fmt_plug.c b/src/sha1_gen_fmt_plug.c
index 63872ea..cce26e4 100644
--- a/src/sha1_gen_fmt_plug.c
+++ b/src/sha1_gen_fmt_plug.c
@@ -118,6 +118,16 @@ static int binary_hash_4(void *binary)
 	return *(ARCH_WORD_32 *)binary & 0xFFFFF;
 }
 
+static int binary_hash_5(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0xFFFFFF;
+}
+
+static int binary_hash_6(void *binary)
+{
+	return *(ARCH_WORD_32 *)binary & 0x7FFFFFF;
+}
+
 static int get_hash_0(int index)
 {
 	return crypt_out[0] & 0xF;
@@ -143,6 +153,16 @@ static int get_hash_4(int index)
 	return crypt_out[0] & 0xFFFFF;
 }
 
+static int get_hash_5(int index)
+{
+	return crypt_out[0] & 0xFFFFFF;
+}
+
+static int get_hash_6(int index)
+{
+	return crypt_out[0] & 0x7FFFFFF;
+}
+
 static int salt_hash(void *salt)
 {
 	unsigned int hash = 0;
@@ -231,7 +251,9 @@ struct fmt_main fmt_sha1_gen = {
 			binary_hash_1,
 			binary_hash_2,
 			binary_hash_3,
-			binary_hash_4
+			binary_hash_4,
+			binary_hash_5,
+			binary_hash_6
 		},
 		salt_hash,
 		set_salt,
@@ -244,7 +266,9 @@ struct fmt_main fmt_sha1_gen = {
 			get_hash_1,
 			get_hash_2,
 			get_hash_3,
-			get_hash_4
+			get_hash_4,
+			get_hash_5,
+			get_hash_6
 		},
 		cmp_all,
 		cmp_all,
-- 
1.7.5.4

