Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 15 Feb 2013 00:34:19 -0800 (PST)
From: deepika dutta <deepikadutta_19@...oo.com>
To: "john-dev@...ts.openwall.com" <john-dev@...ts.openwall.com>
Subject: Re: mschapv2-bitsliced conversion

I am attaching the patch based on unstable-jumbo. It contains the mmx code and also the changes related to P definition. It is working fine (for openmp also) on my 32 bit linux machine. Please test it to ensure it works fine on other platforms too.
 

Cheers,
Deepika


________________________________
 From: deepika dutta <deepikadutta_19@...oo.com>
To: "john-dev@...ts.openwall.com" <john-dev@...ts.openwall.com> 
Sent: Friday, February 15, 2013 11:03 AM
Subject: Re: [john-dev] mschapv2-bitsliced conversion
 

Ok I will do that.

 
Cheers,
Deepika


________________________________
 From: magnum <john.magnum@...hmail.com>
To: john-dev@...ts.openwall.com 
Sent: Friday, February 15, 2013 1:05 AM
Subject: Re: [john-dev] mschapv2-bitsliced conversion
 
On 14 Feb, 2013, at 19:44 , magnum <john.magnum@...hmail.com> wrote:
> I have merged your code with the latest mschapv2-naive version (it now has Freeradius support too) and dropped the old version in favor of this bitslice format. I have tested on x86 32/64 SSE and generic, as well as Sparc32 big-endian. And I ran it through out test suite. Everything seems fine. You can see the changes in unstable-jumbo branch (soon to be Jumbo 8) and bleeding-jumbo branch (future) here:
> https://github.com/magnumripper/JohnTheRipper.git
> 
> Note that your code is now named --format=mschapv2-naive and file is MSCHAPv2_bs_fmt_plug.c. The other (default) format now exploits a weakness so it doesn't use DES at all in the inner loop (massive speedup). But that format loads
 very slow so the BS format is better in some situations. It is also an excellent example for future DES stuff. We should do the same to NETNTLM_old_fmt_plug.c for a starter - it is almost identical to MSCHAPv2.
> 
> There are some whitespace changes, so diff it with -w to see the changes. Please base any future contributions on latest Git. Thanks!
> 
> Solar, I committed this to unstable too. We can revert it if problems surface. Old code is moved to unused/ and modifed so it will happily co-exist with the two others if moved back for testing.

I just realized the new code does not work for -mmx builds. I do not think many people need such a target but I guess we still have to support it. Deepika, could you try to implement one of the follwing?

a) Implement MMX version of DES_bs_crypt_plain() in x86-mmx.S

or

b) Add some #ifdef-ninja so MSCHAPv2 use generic code for MMX builds - without affecting DES and
 LM formats.

Please base this on the unstable-jumbo branch of Github as above.

magnum
[ CONTENT OF TYPE text/html SKIPPED ]

diff -urpN JohnTheRipper-unstable-jumbo/src/DES_bs_b.c JohnTheRipper-unstable-jumbo.new/src/DES_bs_b.c
--- JohnTheRipper-unstable-jumbo/src/DES_bs_b.c	2013-02-14 09:10:22.000000000 +0000
+++ JohnTheRipper-unstable-jumbo.new/src/DES_bs_b.c	2013-02-15 07:12:22.692159519 +0000
@@ -11,7 +11,6 @@
 #include "common.h"
 #include "DES_bs.h"
 
-DES_bs_vector P[64];
 
 #if DES_BS_ASM && defined(_OPENMP) && defined(__GNUC__)
 #warning Assembly code and OpenMP are both requested - will provide the former, but not the latter (for DES-based hashes).  This may likely be corrected by enabling SIMD intrinsics with the C compiler (try adding -msse2 to OMPFLAGS).
diff -urpN JohnTheRipper-unstable-jumbo/src/DES_bs.c JohnTheRipper-unstable-jumbo.new/src/DES_bs.c
--- JohnTheRipper-unstable-jumbo/src/DES_bs.c	2013-02-14 09:10:22.000000000 +0000
+++ JohnTheRipper-unstable-jumbo.new/src/DES_bs.c	2013-02-15 07:05:34.493580533 +0000
@@ -40,6 +40,9 @@ int DES_bs_nt = 0;
 DES_bs_combined *DES_bs_all_p = NULL;
 #elif !DES_BS_ASM
 DES_bs_combined CC_CACHE_ALIGN DES_bs_all;
+#endif
+
+#if !DES_BS_ASM
 DES_bs_vector P[64];
 #endif
 
diff -urpN JohnTheRipper-unstable-jumbo/src/x86-mmx.S JohnTheRipper-unstable-jumbo.new/src/x86-mmx.S
--- JohnTheRipper-unstable-jumbo/src/x86-mmx.S	2013-02-15 08:04:42.978576091 +0000
+++ JohnTheRipper-unstable-jumbo.new/src/x86-mmx.S	2013-02-15 08:05:24.022976209 +0000
@@ -21,6 +21,9 @@
  *
  * The effort has been sponsored by Rapid7: http://www.rapid7.com
  *
+ * Addition of single DES encryption with no salt by Deepika Dutta Mishra
+ * <dipikadutta at gmail.com> in 2013, no rights reserved.
+ *
  * Note: there's some MMX code in x86.S as well (just not for bitslice DES).
  */
 
@@ -34,6 +37,7 @@
 #define DES_bs_crypt			_DES_bs_crypt
 #define DES_bs_crypt_25			_DES_bs_crypt_25
 #define DES_bs_crypt_LM			_DES_bs_crypt_LM
+#define DES_bs_crypt_plain		_DES_bs_crypt_plain
 #endif
 
 /*
@@ -73,6 +77,18 @@
 .bss
 #endif
 
+#ifdef UNDERSCORES
+.globl _P
+DO_ALIGN(5)
+_P:
+DO_SPACE(nvec(64))
+#else
+.globl P
+DO_ALIGN(5)
+P:
+DO_SPACE(nvec(64))
+#endif
+
 .globl DES_bs_all
 DO_ALIGN(5)
 DES_bs_all:
@@ -103,7 +119,11 @@ DO_SPACE(nptr(48))
 #define E(i)				DES_bs_all_E+nptr(i)
 #define B(i)				DES_bs_all_B+nvec(i)
 #define tmp_at(i)			DES_bs_all_tmp+nvec(i)
-
+#ifdef UNDERSCORES
+#define P(i)				_P+nvec(i)
+#else
+#define P(i)				P+nvec(i)
+#endif
 #define pnot				tmp_at(0)
 
 #define S1(out1, out2, out3, out4) \
@@ -1391,6 +1411,194 @@ DES_bs_crypt_LM_loop:
 #endif
 	ret
 
+#define rounds				%eax
+
+DO_ALIGN(5)
+.globl DES_bs_crypt_plain
+DES_bs_crypt_plain:
+	movl $DES_bs_all_xkeys,v_ptr
+	movl $DES_bs_all_K,k_ptr
+	movdqa P(0),%xmm4
+	movdqa %xmm4,B(0)
+	movdqa P(1),%xmm4
+	movdqa %xmm4,B(1)
+	movdqa P(2),%xmm4
+	movdqa %xmm4,B(2)
+	movdqa P(3),%xmm4
+	movdqa %xmm4,B(3)
+	movdqa P(4),%xmm4
+	movdqa %xmm4,B(4)
+	movdqa P(5),%xmm4
+	movdqa %xmm4,B(5)
+	movdqa P(6),%xmm4
+	movdqa %xmm4,B(6)
+	movdqa P(7),%xmm4
+	movdqa %xmm4,B(7)
+	movdqa P(8),%xmm4
+	movdqa %xmm4,B(8)
+	movdqa P(9),%xmm4
+	movdqa %xmm4,B(9)
+	movdqa P(10),%xmm4
+	movdqa %xmm4,B(10)
+	movdqa P(11),%xmm4
+	movdqa %xmm4,B(11)
+	movdqa P(12),%xmm4
+	movdqa %xmm4,B(12)
+	movdqa P(13),%xmm4
+	movdqa %xmm4,B(13)
+	movdqa P(14),%xmm4
+	movdqa %xmm4,B(14)
+	movdqa P(15),%xmm4
+	movdqa %xmm4,B(15)
+	movdqa P(16),%xmm4
+	movdqa %xmm4,B(16)
+	movdqa P(17),%xmm4
+	movdqa %xmm4,B(17)
+	movdqa P(18),%xmm4
+	movdqa %xmm4,B(18)
+	movdqa P(19),%xmm4
+	movdqa %xmm4,B(19)
+	movdqa P(20),%xmm4
+	movdqa %xmm4,B(20)
+	movdqa P(21),%xmm4
+	movdqa %xmm4,B(21)
+	movdqa P(22),%xmm4
+	movdqa %xmm4,B(22)
+	movdqa P(23),%xmm4
+	movdqa %xmm4,B(23)
+	movdqa P(24),%xmm4
+	movdqa %xmm4,B(24)
+	movdqa P(25),%xmm4
+	movdqa %xmm4,B(25)
+	movdqa P(26),%xmm4
+	movdqa %xmm4,B(26)
+	movdqa P(27),%xmm4
+	movdqa %xmm4,B(27)
+	movdqa P(28),%xmm4
+	movdqa %xmm4,B(28)
+	movdqa P(29),%xmm4
+	movdqa %xmm4,B(29)
+	movdqa P(30),%xmm4
+	movdqa %xmm4,B(30)
+	movdqa P(31),%xmm4
+	movdqa %xmm4,B(31)
+	movdqa P(32),%xmm4
+	movdqa %xmm4,B(32)
+	movdqa P(33),%xmm4
+	movdqa %xmm4,B(33)
+	movdqa P(34),%xmm4
+	movdqa %xmm4,B(34)
+	movdqa P(35),%xmm4
+	movdqa %xmm4,B(35)
+	movdqa P(36),%xmm4
+	movdqa %xmm4,B(36)
+	movdqa P(37),%xmm4
+	movdqa %xmm4,B(37)
+	movdqa P(38),%xmm4
+	movdqa %xmm4,B(38)
+	movdqa P(39),%xmm4
+	movdqa %xmm4,B(39)
+	movdqa P(40),%xmm4
+	movdqa %xmm4,B(40)
+	movdqa P(41),%xmm4
+	movdqa %xmm4,B(41)
+	movdqa P(42),%xmm4
+	movdqa %xmm4,B(42)
+	movdqa P(43),%xmm4
+	movdqa %xmm4,B(43)
+	movdqa P(44),%xmm4
+	movdqa %xmm4,B(44)
+	movdqa P(45),%xmm4
+	movdqa %xmm4,B(45)
+	movdqa P(46),%xmm4
+	movdqa %xmm4,B(46)
+	movdqa P(47),%xmm4
+	movdqa %xmm4,B(47)
+	movdqa P(48),%xmm4
+	movdqa %xmm4,B(48)
+	movdqa P(49),%xmm4
+	movdqa %xmm4,B(49)
+	movdqa P(50),%xmm4
+	movdqa %xmm4,B(50)
+	movdqa P(51),%xmm4
+	movdqa %xmm4,B(51)
+	movdqa P(52),%xmm4
+	movdqa %xmm4,B(52)
+	movdqa P(53),%xmm4
+	movdqa %xmm4,B(53)
+	movdqa P(54),%xmm4
+	movdqa %xmm4,B(54)
+	movdqa P(55),%xmm4
+	movdqa %xmm4,B(55)
+	movdqa P(56),%xmm4
+	movdqa %xmm4,B(56)
+	movdqa P(57),%xmm4
+	movdqa %xmm4,B(57)
+	movdqa P(58),%xmm4
+	movdqa %xmm4,B(58)
+	movdqa P(59),%xmm4
+	movdqa %xmm4,B(59)
+	movdqa P(60),%xmm4
+	movdqa %xmm4,B(60)
+	movdqa P(61),%xmm4
+	movdqa %xmm4,B(61)
+	movdqa P(62),%xmm4
+	movdqa %xmm4,B(62)
+	movdqa P(63),%xmm4
+	movdqa %xmm4,B(63)
+
+DES_bs_finalize_keys_plain_loop:
+	FINALIZE_NEXT_KEY_BITS_0_6
+	addl $nvec(7),k_ptr
+	addl $nvec(8),v_ptr
+	cmpl $DES_bs_all_K+nvec(56),k_ptr
+	jb DES_bs_finalize_keys_plain_loop
+	pushl %esi
+	movl $DES_bs_all_KS_p,k_ptr
+	movl $DES_bs_all_KS_v,v_ptr
+	movl $8,rounds
+DES_bs_crypt_plain_loop:
+	xor_B_KS_p(31, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5)
+	S1(B(40), B(48), B(54), B(62))
+	xor_B_KS_p(3, 6, 4, 7, 5, 8, 6, 9, 7, 10, 8, 11)
+	S2(B(44), B(59), B(33), B(49))
+	xor_B_KS_p(7, 12, 8, 13, 9, 14, 10, 15, 11, 16, 12, 17)
+	S3(B(55), B(47), B(61), B(37))
+	xor_B_KS_p(11, 18, 12, 19, 13, 20, 14, 21, 15, 22, 16, 23)
+	S4(B(57), B(51), B(41), B(32))
+	xor_B_KS_p(15, 24, 16, 25, 17, 26, 18, 27, 19, 28, 20, 29)
+	S5(B(39), B(45), B(56), B(34))
+	xor_B_KS_p(19, 30, 20, 31, 21, 32, 22, 33, 23, 34, 24, 35)
+	S6(B(35), B(60), B(42), B(50))
+	xor_B_KS_p(23, 36, 24, 37, 25, 38, 26, 39, 27, 40, 28, 41)
+	S7(B(63), B(43), B(53), B(38))
+	xor_B_KS_p(27, 42, 28, 43, 29, 44, 30, 45, 31, 46, 0, 47)
+	S8(B(36), B(58), B(46), B(52))
+	xor_B_KS_p(63, 48, 32, 49, 33, 50, 34, 51, 35, 52, 36, 53)
+	S1(B(8), B(16), B(22), B(30))
+	xor_B_KS_p(35, 54, 36, 55, 37, 56, 38, 57, 39, 58, 40, 59)
+	S2(B(12), B(27), B(1), B(17))
+	xor_B_KS_p(39, 60, 40, 61, 41, 62, 42, 63, 43, 64, 44, 65)
+	S3(B(23), B(15), B(29), B(5))
+	xor_B_KS_p(43, 66, 44, 67, 45, 68, 46, 69, 47, 70, 48, 71)
+	S4(B(25), B(19), B(9), B(0))
+	xor_B_KS_p(47, 72, 48, 73, 49, 74, 50, 75, 51, 76, 52, 77)
+	S5(B(7), B(13), B(24), B(2))
+	xor_B_KS_p(51, 78, 52, 79, 53, 80, 54, 81, 55, 82, 56, 83)
+	S6(B(3), B(28), B(10), B(18))
+	xor_B_KS_p(55, 84, 56, 85, 57, 86, 58, 87, 59, 88, 60, 89)
+	S7(B(31), B(11), B(21), B(6))
+	xor_B_KS_p(59, 90, 60, 91, 61, 92, 62, 93, 63, 94, 32, 95)
+	addl $nptr(96),k_ptr
+	S8(B(4), B(26), B(14), B(20))
+	decl rounds
+	jnz DES_bs_crypt_plain_loop
+	popl %esi
+#ifdef EMMS
+	emms
+#endif
+	ret
+
 #endif
 
 #if defined(__ELF__) && defined(__linux__)

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ