diff -urpN john/src/DES_bs_b.c john-1.7.9-jumbo-5/src/DES_bs_b.c --- john/src/DES_bs_b.c 2012-05-27 09:48:54.685044984 +0000 +++ john-1.7.9-jumbo-5/src/DES_bs_b.c 2011-11-19 02:57:47.000000000 +0000 @@ -1561,99 +1561,3 @@ void DES_bs_crypt_LM(int keys_count) } } #endif - -// one des encryption// -#undef kd -#define kd - -void DES_bs_crypt_one(int keys_count) -{ -for_each_t(n) { - DES_bs_vector *k; - int rounds; - int i; - - DES_bs_finalize_keys(); -#if DES_BS_EXPAND - k = DES_bs_all.KS.v; -#else - k = DES_bs_all.KS.p; -#endif - - rounds = 8; - - for(i=0; i<64; i++) - DES_bs_all.B[i] = Plaintext[i]; - - do { - for_each_depth() - s1(y(31, 0), y(0, 1), y(1, 2), - y(2, 3), y(3, 4), y(4, 5), - z(40), z(48), z(54), z(62)); - for_each_depth() - s2(y(3, 6), y(4, 7), y(5, 8), - y(6, 9), y(7, 10), y(8, 11), - z(44), z(59), z(33), z(49)); - for_each_depth() - s3(y(7, 12), y(8, 13), y(9, 14), - y(10, 15), y(11, 16), y(12, 17), - z(55), z(47), z(61), z(37)); - for_each_depth() - s4(y(11, 18), y(12, 19), y(13, 20), - y(14, 21), y(15, 22), y(16, 23), - z(57), z(51), z(41), z(32)); - for_each_depth() - s5(y(15, 24), y(16, 25), y(17, 26), - y(18, 27), y(19, 28), y(20, 29), - z(39), z(45), z(56), z(34)); - for_each_depth() - s6(y(19, 30), y(20, 31), y(21, 32), - y(22, 33), y(23, 34), y(24, 35), - z(35), z(60), z(42), z(50)); - for_each_depth() - s7(y(23, 36), y(24, 37), y(25, 38), - y(26, 39), y(27, 40), y(28, 41), - z(63), z(43), z(53), z(38)); - for_each_depth() - s8(y(27, 42), y(28, 43), y(29, 44), - y(30, 45), y(31, 46), y(0, 47), - z(36), z(58), z(46), z(52)); - - for_each_depth() - s1(y(63, 48), y(32, 49), y(33, 50), - y(34, 51), y(35, 52), y(36, 53), - z(8), z(16), z(22), z(30)); - for_each_depth() - s2(y(35, 54), y(36, 55), y(37, 56), - y(38, 57), y(39, 58), y(40, 59), - z(12), z(27), z(1), z(17)); - for_each_depth() - s3(y(39, 60), y(40, 61), y(41, 62), - y(42, 63), y(43, 64), y(44, 65), - z(23), z(15), z(29), z(5)); - for_each_depth() - s4(y(43, 66), y(44, 67), y(45, 68), - y(46, 69), y(47, 70), y(48, 71), - z(25), z(19), z(9), z(0)); - for_each_depth() - s5(y(47, 72), y(48, 73), y(49, 74), - y(50, 75), y(51, 76), y(52, 77), - z(7), z(13), z(24), z(2)); - for_each_depth() - s6(y(51, 78), y(52, 79), y(53, 80), - y(54, 81), y(55, 82), y(56, 83), - z(3), z(28), z(10), z(18)); - for_each_depth() - s7(y(55, 84), y(56, 85), y(57, 86), - y(58, 87), y(59, 88), y(60, 89), - z(31), z(11), z(21), z(6)); - for_each_depth() - s8(y(59, 90), y(60, 91), y(61, 92), - y(62, 93), y(63, 94), y(32, 95), - z(4), z(26), z(14), z(20)); - - k += 96; - } while (--rounds); -} -} - diff -urpN john/src/DES_bs.c john-1.7.9-jumbo-5/src/DES_bs.c --- john/src/DES_bs.c 2012-05-26 22:04:05.881696000 +0000 +++ john-1.7.9-jumbo-5/src/DES_bs.c 2011-12-15 20:57:19.000000000 +0000 @@ -97,16 +97,10 @@ void DES_bs_init(int LM, int cpt) for_each_t(n) { #if DES_BS_EXPAND - //set k for LM = 2 // - if (LM){ - if(LM == 2) - k = DES_bs_all.KSp; - else - k = DES_bs_all.KS.p; - } + if (LM) + k = DES_bs_all.KS.p; else k = DES_bs_all.KSp; - #else k = DES_bs_all.KS.p; #endif @@ -123,8 +117,7 @@ void DES_bs_init(int LM, int cpt) bit ^= 070; bit -= bit >> 3; bit = 55 - bit; - //do only for LM = 1// - if (LM == 1) bit = DES_LM_KP[bit]; + if (LM) bit = DES_LM_KP[bit]; *k++ = &DES_bs_all.K[bit] START; } } @@ -137,8 +130,7 @@ void DES_bs_init(int LM, int cpt) DES_bs_all.pxkeys[index] = &DES_bs_all.xkeys.c[0][index & 7][index >> 3]; - //for LM=2, no salt and no upper case conversion// - if (LM ==1) { + if (LM) { for (c = 0; c < 0x100; c++) #ifdef BENCH_BUILD if (c >= 'a' && c <= 'z') @@ -148,7 +140,7 @@ void DES_bs_init(int LM, int cpt) #else DES_bs_all.E.u[c] = CP_up[c]; #endif - } else if(LM==0) { + } else { for (index = 0; index < 48; index++) DES_bs_all.Ens[index] = &DES_bs_all.B[DES_E[index]]; diff -urpN john/src/DES_bs.h john-1.7.9-jumbo-5/src/DES_bs.h --- john/src/DES_bs.h 2012-05-26 23:09:50.065667047 +0000 +++ john-1.7.9-jumbo-5/src/DES_bs.h 2011-11-23 06:54:50.000000000 +0000 @@ -54,7 +54,7 @@ typedef struct { } E; DES_bs_vector K[56]; /* Keys */ DES_bs_vector B[64]; /* Data blocks */ - #if DES_BS_ASM +#if DES_BS_ASM DES_bs_vector tmp[16]; /* Miscellaneous temporary storage */ #else DES_bs_vector zero; /* All 0 bits */ @@ -71,9 +71,6 @@ typedef struct { DES_bs_vector *Ens[48]; /* Pointers into B[] for non-salted E */ } DES_bs_combined; -//store plaintext// -DES_bs_vector Plaintext[64]; - #if defined(_OPENMP) && !DES_BS_ASM #define DES_bs_mt 1 #define DES_bs_cpt 32 @@ -183,5 +180,4 @@ extern int DES_bs_cmp_all(ARCH_WORD *bin */ extern int DES_bs_cmp_one(ARCH_WORD *binary, int count, int index); -extern void DES_bs_crypt_one(int keys_count); #endif diff -urpN john/src/DES_fmt.c john-1.7.9-jumbo-5/src/DES_fmt.c --- john/src/DES_fmt.c 2012-05-27 09:42:06.959097297 +0000 +++ john-1.7.9-jumbo-5/src/DES_fmt.c 2012-05-27 09:59:44.121922817 +0000 @@ -77,7 +77,6 @@ struct fmt_main fmt_DES; static void init(struct fmt_main *pFmt) { DES_bs_init(0, DES_bs_cpt); - #if DES_bs_mt fmt_DES.params.min_keys_per_crypt = DES_bs_min_kpc; fmt_DES.params.max_keys_per_crypt = DES_bs_max_kpc; @@ -373,7 +372,7 @@ struct fmt_main fmt_DES = { #else DES_std_get_binary, #endif - + salt, { binary_hash_0, diff -urpN john/src/DES_std.c john-1.7.9-jumbo-5/src/DES_std.c --- john/src/DES_std.c 2012-05-27 09:42:47.057983280 +0000 +++ john-1.7.9-jumbo-5/src/DES_std.c 2011-12-15 20:57:19.000000000 +0000 @@ -269,7 +269,7 @@ unsigned char DES_E[48] = { 27, 28, 29, 30, 31, 0 }; -unsigned char DES_IP[64] = { +static unsigned char DES_IP[64] = { 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, diff -urpN john/src/MSCHAPv2_fmt_plug.c john-1.7.9-jumbo-5/src/MSCHAPv2_fmt_plug.c --- john/src/MSCHAPv2_fmt_plug.c 2012-05-26 22:18:07.657691000 +0000 +++ john-1.7.9-jumbo-5/src/MSCHAPv2_fmt_plug.c 2011-12-15 22:24:44.000000000 +0000 @@ -23,7 +23,7 @@ * http://freeradius.org/rfc/rfc2759.txt * */ -#include "DES_bs.h" + #include #ifdef _OPENMP #include @@ -36,9 +36,7 @@ #include "memory.h" #include "sha.h" - -//Initial permutation// -extern unsigned char DES_IP[64]; +#include #ifndef uchar #define uchar unsigned char @@ -65,10 +63,7 @@ extern unsigned char DES_IP[64]; #ifdef _OPENMP #define MAX_KEYS_PER_CRYPT 0x10000 #else -//#define MAX_KEYS_PER_CRYPT THREAD_RATIO - -//set to DES_BS_DEPTH for bitsliced des// -#define MAX_KEYS_PER_CRYPT DES_BS_DEPTH +#define MAX_KEYS_PER_CRYPT THREAD_RATIO #endif static struct fmt_tests tests[] = { @@ -95,8 +90,6 @@ static uchar (*output)[PARTIAL_BINARY_SI static uchar *challenge; static int keys_prepared; -static void mschapv2_set_salt(void *salt); - #include "unicode.h" static void init(struct fmt_main *pFmt) @@ -117,11 +110,8 @@ static void init(struct fmt_main *pFmt) saved_len = mem_calloc_tiny(sizeof(*saved_len) * pFmt->params.max_keys_per_crypt, MEM_ALIGN_WORD); saved_key = mem_calloc_tiny(sizeof(*saved_key) * pFmt->params.max_keys_per_crypt, MEM_ALIGN_NONE); output = mem_alloc_tiny(sizeof(*output) * pFmt->params.max_keys_per_crypt, MEM_ALIGN_WORD); - - //LM =2 for one DES encryption// - DES_bs_init(2, DES_bs_cpt); - } + static int mschapv2_valid(char *ciphertext, struct fmt_main *pFmt) { char *pos, *pos2; @@ -229,63 +219,29 @@ static void *mschapv2_get_binary(char *c return binary; } -static inline void setup_des_key(unsigned char key_56[], int index) +static inline void setup_des_key(unsigned char key_56[], DES_key_schedule *ks) { - char key[8]; + DES_cblock key; - //left shifted by one to bring key in openssl format// - key[0] = (key_56[0])>>1; - key[1] = ((key_56[0] << 7) | (key_56[1] >> 1)) >>1; - key[2] = ((key_56[1] << 6) | (key_56[2] >> 2)) >>1; - key[3] = ((key_56[2] << 5) | (key_56[3] >> 3)) >>1; - key[4] = ((key_56[3] << 4) | (key_56[4] >> 4)) >>1; - key[5] = ((key_56[4] << 3) | (key_56[5] >> 5)) >>1; - key[6] = ((key_56[5] << 2) | (key_56[6] >> 6)) >>1; - key[7] = ((key_56[6] << 1)) >>1; - - DES_bs_set_key((char*)key, index); -} - -//generates output buffer// -void generate_output(int count) -{ - int i, j; - char *cipher; - char temp; - - unsigned char inv_ip[64] = { - 39, 7, 47, 15, 55, 23, 63, 31, - 38, 6, 46, 14, 54, 22, 62, 30, - 37, 5, 45, 13, 53, 21, 61, 29, - 36, 4, 44, 12, 52, 20, 60, 28, - 35, 3, 43, 11, 51, 19, 59, 27, - 34, 2, 42, 10, 50, 18, 58, 26, - 33, 1, 41, 9, 49, 17, 57, 25, - 32, 0, 40, 8, 48, 16, 56, 24, - }; - - for(i=0; i> i) & 0x01); - cipher[j>>3] |= temp << (7 - j%8); - } - - } + key[0] = key_56[0]; + key[1] = (key_56[0] << 7) | (key_56[1] >> 1); + key[2] = (key_56[1] << 6) | (key_56[2] >> 2); + key[3] = (key_56[2] << 5) | (key_56[3] >> 3); + key[4] = (key_56[3] << 4) | (key_56[4] >> 4); + key[5] = (key_56[4] << 3) | (key_56[5] >> 5); + key[6] = (key_56[5] << 2) | (key_56[6] >> 6); + key[7] = (key_56[6] << 1); + DES_set_key(&key, ks); } /* Calculate the MSCHAPv2 response for the given challenge, using the specified authentication identity (username), password and client nonce. */ - static void mschapv2_crypt_all(int count) { - + DES_key_schedule ks; int i; if (!keys_prepared) { @@ -308,17 +264,14 @@ static void mschapv2_crypt_all(int count #ifdef _OPENMP #pragma omp parallel for default(none) private(i, ks) shared(count, output, challenge, saved_key) #endif - //bitsliced des encryption// - - for(i=0; i> 3] >> (7 - (cnt & 7))) & 1); - if(j==0) - Plaintext[i] = 0; - else - Plaintext[i] = -1; - } - + challenge = salt; } static void mschapv2_set_key(char *key, int index) diff -urpN john/src/sboxes-s.c john-1.7.9-jumbo-5/src/sboxes-s.c --- john/src/sboxes-s.c 2012-05-07 20:39:34.000000000 +0000 +++ john-1.7.9-jumbo-5/src/sboxes-s.c 2011-06-21 23:56:01.000000000 +0000 @@ -41,7 +41,7 @@ #if regs >= 17 || latency >= 3 /* s1-000010, 36 gates, 17 regs, 8/28/65/102/139 stall cycles */ -static void +MAYBE_INLINE static void s1(vtype a1, vtype a2, vtype a3, vtype a4, vtype a5, vtype a6, vtype * out1, vtype * out2, vtype * out3, vtype * out4) { @@ -173,7 +173,7 @@ s1(vtype a1, vtype a2, vtype a3, vtype a #if regs >= 18 && latency <= 2 /* s2-000000, 33 gates, 18 regs, 3/26/57/90/125 stall cycles */ -static void +MAYBE_INLINE static void s2(vtype a1, vtype a2, vtype a3, vtype a4, vtype a5, vtype a6, vtype * out1, vtype * out2, vtype * out3, vtype * out4) { @@ -419,7 +419,7 @@ s3(vtype a1, vtype a2, vtype a3, vtype a } #else /* s3-000004, 33 gates, 17 regs, 3/13/41/77/113 stall cycles */ -static void +MAYBE_INLINE static void s3(vtype a1, vtype a2, vtype a3, vtype a4, vtype a5, vtype a6, vtype * out1, vtype * out2, vtype * out3, vtype * out4) { @@ -482,7 +482,7 @@ s3(vtype a1, vtype a2, vtype a3, vtype a #if regs >= 13 /* s4-000014, 26 gates, 13 regs, 2/17/42/70/98 stall cycles */ -static void +MAYBE_INLINE static void s4(vtype a1, vtype a2, vtype a3, vtype a4, vtype a5, vtype a6, vtype * out1, vtype * out2, vtype * out3, vtype * out4) { @@ -775,7 +775,7 @@ s5(vtype a1, vtype a2, vtype a3, vtype a } #elif regs >= 20 /* s5-000016, 35 gates, 20 regs, 6/30/62/98/135 stall cycles */ -static void +MAYBE_INLINE static void s5(vtype a1, vtype a2, vtype a3, vtype a4, vtype a5, vtype a6, vtype * out1, vtype * out2, vtype * out3, vtype * out4) { @@ -903,7 +903,7 @@ s5(vtype a1, vtype a2, vtype a3, vtype a #if regs >= 16 && latency <= 2 /* s6-000000, 34 gates, 16 regs, 5/34/70/107/144 stall cycles */ -static void +MAYBE_INLINE static void s6(vtype a1, vtype a2, vtype a3, vtype a4, vtype a5, vtype a6, vtype * out1, vtype * out2, vtype * out3, vtype * out4) { @@ -1215,7 +1215,7 @@ s7(vtype a1, vtype a2, vtype a3, vtype a } #else /* s7-000019, 34 gates, 17 regs, 5/28/57/88/119 stall cycles */ -static void +MAYBE_INLINE static void s7(vtype a1, vtype a2, vtype a3, vtype a4, vtype a5, vtype a6, vtype * out1, vtype * out2, vtype * out3, vtype * out4) { @@ -1339,7 +1339,7 @@ s8(vtype a1, vtype a2, vtype a3, vtype a } #else /* s8-000037, 32 gates, 15 regs, 3/17/49/81/113 stall cycles */ -static void +MAYBE_INLINE static void s8(vtype a1, vtype a2, vtype a3, vtype a4, vtype a5, vtype a6, vtype * out1, vtype * out2, vtype * out3, vtype * out4) {