📄 x86-mmx.s
字号:
/* * This file is part of John the Ripper password cracker, * Copyright (c) 2000 by Solar Designer and others: * * The MMX DES S-box code is by Bruce Ford and R閙i Guyomarch, originally * for use in the distributed.net clients, included here with permission. * Only minor modifications have been made to their S-box code. Optimized * S-box expressions are based on work by Matthew Kwan (see nonstd.c). * * Note: there's some MMX code in x86.S as well. */#ifdef UNDERSCORES#define DES_bs_all _DES_bs_all#define DES_bs_init_asm _DES_bs_init_asm#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#endif/* * Some broken systems don't offer section alignments larger than 4 bytes, * while for the MMX code we need at least an 8 byte alignment. ALIGN_FIX * is here to work around this issue when we happen to get bad addresses. */#ifndef ALIGN_FIX#ifdef ALIGN_LOG#define DO_ALIGN(log) .align (log)#else#define DO_ALIGN(log) .align (1 << (log))#endif#else#ifdef ALIGN_LOG#define DO_ALIGN(log) .align (log); .space 4#else#define DO_ALIGN(log) .align (1 << (log)); .space 4#endif#endif#ifdef BSD.data#else.bss#endif.globl DES_bs_allDO_ALIGN(5)DES_bs_all:DES_bs_all_KSp:.space (0x300 * 4)DES_bs_all_KS_p:DES_bs_all_KS_v:.space (0x300 * 8)DES_bs_all_E:.space (96 * 4)DES_bs_all_K:.space (56 * 8)DES_bs_all_B:.space (64 * 8)DES_bs_all_tmp:.space (16 * 8)DES_bs_all_s:.space 0x100#define E(i) DES_bs_all_E+(i)*4#define B(i) DES_bs_all_B+(i)*8#define tmp_at(i) DES_bs_all_tmp+(i)*8#define pnot tmp_at(0)#define a1 %mm0#define a2 %mm1#define a3 %mm2#define a4 %mm3#define a5 %mm4#define a6 %mm5#define S1_out1 %mm5#define S1_out2 %mm7#define S1_out3 %mm2#define S1_out4 %mm0#define S1_a1 tmp_at(1)#define S1_a3 tmp_at(2)#define S1_a5 tmp_at(3)#define S1_x1 tmp_at(4)#define S1_x3 tmp_at(5)#define S1_x4 tmp_at(6)#define S1_x5 tmp_at(7)#define S1_x6 tmp_at(8)#define S1_x13 tmp_at(9)#define S1_x14 tmp_at(10)#define S1_x25 tmp_at(11)#define S1_x26 tmp_at(12)#define S1_x38 tmp_at(13)#define S1_x55 tmp_at(14)#define S1_x58 tmp_at(15)#define S1(out1, out2, out3, out4, extra) \ movq %mm0,S1_a1; \ movq %mm3,%mm6; \ pxor pnot,%mm0; \ pxor %mm2,%mm3; \ pxor pnot,%mm6; \ movq %mm0,%mm7; \ extra; \ movq %mm4,S1_a5; \ por %mm2,%mm7; \ movq %mm3,S1_x3; \ movq %mm5,%mm4; \ movq %mm6,S1_x1; \ pxor %mm0,%mm3; \ movq %mm7,S1_x5; \ por %mm6,%mm0; \ movq %mm2,S1_a3; \ pand %mm6,%mm7; \ movq %mm3,S1_x4; \ por %mm3,%mm2; \ pxor pnot,%mm2; \ pand %mm0,%mm4; \ movq %mm7,%mm6; \ por %mm5,%mm2; \ movq %mm7,S1_x6; \ por %mm5,%mm6; \ pxor %mm2,%mm7; \ pxor %mm6,%mm3; \ movq %mm2,S1_x25; \ pxor %mm4,%mm6; \ pand S1_a3,%mm4; \ movq %mm6,%mm2; \ pxor S1_a3,%mm6; \ por %mm1,%mm2; \ pand S1_x5,%mm6; \ pxor %mm3,%mm2; \ movq %mm4,S1_x38; \ pxor %mm2,%mm0; \ movq %mm7,S1_x26; \ movq %mm5,%mm4; \ movq %mm2,S1_x13; \ por %mm0,%mm4; \ movq S1_x1,%mm7; \ por %mm1,%mm6; \ movq %mm0,S1_x14; \ movq %mm3,%mm2; \ pandn S1_x3,%mm0; \ pxor %mm7,%mm4; \ por S1_x4,%mm5; \ por %mm1,%mm0; \ pxor S1_x38,%mm5; \ pxor %mm0,%mm4; \ movq S1_a5,%mm0; \ pand %mm7,%mm2; \ movq %mm6,S1_x55; \ por %mm1,%mm2; \ movq S1_x14,%mm6; \ por %mm4,%mm0; \ pand S1_x5,%mm6; \ por %mm3,%mm7; \ movq %mm5,S1_x58; \ pxor %mm3,%mm6; \ pxor S1_x6,%mm7; \ movq %mm1,%mm5; \ pxor S1_x26,%mm2; \ pand %mm6,%mm5; \ pand S1_a3,%mm6; \ pxor %mm7,%mm5; \ por S1_a5,%mm5; \ movq S1_a1,%mm7; \ pxor %mm2,%mm5; \ movq S1_x4,%mm2; \ por %mm3,%mm7; \ por S1_x38,%mm2; \ pxor %mm6,%mm3; \ pxor S1_x25,%mm6; \ pxor %mm4,%mm7; \ movq S1_a3,%mm4; \ por %mm1,%mm7; \ por S1_x26,%mm4; \ por %mm1,%mm6; \ pxor S1_x14,%mm4; \ pxor %mm2,%mm6; \ movq S1_x13,%mm2; \ pxor %mm4,%mm7; \ pxor S1_x55,%mm3; \ pxor %mm2,%mm0; \ pxor out1,%mm5; \ pand %mm3,%mm2; \ movq S1_a5,%mm4; \ pand %mm1,%mm2; \ movq %mm5,out1; \ pxor S1_x58,%mm2; \ pand %mm4,%mm7; \ pxor out4,%mm0; \ pand %mm4,%mm2; \ pxor out2,%mm7; \ movq %mm0,out4; \ pxor out3,%mm2; \ pxor %mm6,%mm7; \ pxor %mm3,%mm2; \ movq %mm7,out2; \ movq %mm2,out3#define S2_out1 %mm1#undef S2_out2#define S2_out3 %mm7#define S2_out4 %mm2#define S2_a1 tmp_at(1)#define S2_a2 tmp_at(2)#define S2_a3 tmp_at(3)#define S2_a4 tmp_at(4)#define S2_x3 tmp_at(5)#define S2_x4 tmp_at(6)#define S2_x5 tmp_at(7)#define S2_x13 tmp_at(8)#define S2_x18 tmp_at(9)#define S2_x25 tmp_at(10)#define S2(out1, out2, out3, out4, extra) \ movq %mm3,S2_a4; \ movq %mm4,%mm6; \ extra; \ movq %mm0,S2_a1; \ movq %mm4,%mm7; \ pxor pnot,%mm0; \ pxor %mm5,%mm6; \ pxor pnot,%mm7; \ movq %mm0,%mm3; \ movq %mm2,S2_a3; \ por %mm5,%mm7; \ movq %mm6,S2_x3; \ por %mm7,%mm3; \ pxor %mm4,%mm7; \ pxor %mm0,%mm6; \ pand %mm1,%mm3; \ por %mm7,%mm2; \ movq %mm1,S2_a2; \ pxor %mm5,%mm3; \ movq %mm6,S2_x4; \ pxor %mm1,%mm6; \ movq %mm7,S2_x13; \ pand %mm3,%mm1; \ pand S2_a3,%mm3; \ pxor %mm2,%mm1; \ movq S2_x4,%mm7; \ movq %mm1,%mm2; \ pand S2_a4,%mm2; \ pxor %mm6,%mm3; \ movq %mm6,S2_x5; \ pxor %mm2,%mm3; \ movq S2_a1,%mm2; \ por %mm5,%mm7; \ por %mm2,%mm1; \ pand %mm3,%mm7; \ pxor out2,%mm3; \ por %mm4,%mm2; \ por S2_a3,%mm7; \ movq %mm2,%mm6; \ pxor S2_x13,%mm1; \ por %mm5,%mm6; \ movq %mm3,out2; \ pand %mm0,%mm4; \ movq S2_x13,%mm3; \ por %mm0,%mm5; \ movq %mm2,S2_x18; \ pxor %mm6,%mm3; \ movq S2_a2,%mm2; \ pxor %mm6,%mm0; \ pxor %mm2,%mm3; \ pand %mm2,%mm0; \ pxor %mm3,%mm7; \ por %mm4,%mm2; \ pxor S2_x3,%mm4; \ pand %mm3,%mm6; \ pxor %mm0,%mm4; \ pxor %mm5,%mm6; \ movq %mm7,S2_x25; \ pand %mm3,%mm0; \ movq S2_a3,%mm7; \ pxor %mm2,%mm5; \ pxor S2_x5,%mm0; \ pand %mm4,%mm7; \ pand S2_a2,%mm4; \ pxor %mm5,%mm7; \ por S2_a4,%mm7; \ movq %mm1,%mm5; \ por S2_a3,%mm5; \ por %mm2,%mm1; \ pand S2_x18,%mm2; \ pxor %mm3,%mm4; \ movq S2_a4,%mm3; \ pand %mm4,%mm2; \ pand S2_a3,%mm4; \ pxor %mm5,%mm0; \ pxor S2_x25,%mm7; \ pxor %mm6,%mm4; \ pxor out3,%mm7; \ pand %mm3,%mm1; \ por %mm3,%mm2; \ pxor out1,%mm1; \ pxor %mm4,%mm2; \ pxor %mm0,%mm1; \ pxor out4,%mm2; \ movq %mm1,out1; \ movq %mm7,out3; \ movq %mm2,out4#define S3_out1 %mm2#define S3_out2 %mm6#define S3_out3 %mm3#define S3_out4 %mm7#define S3_a1 tmp_at(1)#define S3_x2 tmp_at(2)#define S3_x9 tmp_at(3)#define S3_a5 tmp_at(4)#define S3_x4 tmp_at(5)#define S3_a6 tmp_at(6)#define S3_x6 tmp_at(7)#define S3_x5 tmp_at(8)#define S3_x11 tmp_at(9)#define S3_x12 tmp_at(10)#define S3_x13 tmp_at(11)#define S3_x54 tmp_at(12)#define S3_x7 tmp_at(13)#define S3_a4 tmp_at(14)#define S3_a3 S3_a5#define S3_x38 S3_x4#define S3(out1, out2, out3, out4, extra) \ movq %mm0,S3_a1; \ extra; \ movq %mm4,%mm0; \ movq %mm5,%mm6; \ pxor pnot,%mm6; \ movq %mm4,%mm7; \ pxor %mm6,%mm7; \ movq %mm6,S3_x2; \ pand %mm2,%mm0; \ movq %mm7,S3_x9; \ pxor %mm5,%mm0; \ movq %mm4,S3_a5; \ pandn %mm3,%mm4; \ movq %mm0,S3_x4; \ por %mm3,%mm7; \ movq S3_a5,%mm6; \ pxor %mm4,%mm0; \ movq %mm5,S3_a6; \ pandn %mm2,%mm6; \ movq %mm0,S3_x6; \ pxor %mm6,%mm7; \ movq S3_x2,%mm5; \ pxor %mm1,%mm0; \ movq %mm4,S3_x5; \ movq %mm7,%mm4; \ por S3_x4,%mm5; \ pand %mm0,%mm4; \ movq %mm7,S3_x11; \ pxor %mm5,%mm6; \ pxor S3_a5,%mm7; \ por %mm1,%mm6; \ movq %mm4,S3_x12; \ pand %mm5,%mm4; \ movq %mm7,S3_x13; \ por %mm0,%mm7; \ movq %mm4,S3_x54; \ movq %mm2,%mm4; \ pxor S3_x9,%mm4; \ pand %mm3,%mm7; \ movq %mm0,S3_x7; \ pxor %mm3,%mm4; \ pxor S3_a6,%mm5; \ pxor %mm4,%mm6; \ movq %mm3,S3_a4; \ por %mm5,%mm3; \ movq %mm2,S3_a3; \ pxor %mm3,%mm5; \ por %mm1,%mm5; \ pxor %mm7,%mm2; \ pxor S3_x12,%mm7; \ movq %mm2,%mm4; \ por S3_x5,%mm2; \ pand %mm1,%mm7; \ por S3_x4,%mm4; \ por %mm1,%mm2; \ pxor S3_x11,%mm7; \ pxor %mm3,%mm2; \ movq S3_a1,%mm3; \ pxor S3_a4,%mm4; \ pand %mm3,%mm7; \ pxor S3_x7,%mm7; \ por %mm3,%mm2; \ movq %mm4,S3_x38; \ pxor %mm6,%mm2; \ pxor out4,%mm7; \ por %mm1,%mm4; \ movq S3_a3,%mm6; \ movq %mm2,%mm3; \ pxor S3_x9,%mm6; \ por S3_x5,%mm6; \ pxor S3_x38,%mm3; \ pxor %mm6,%mm4; \ movq S3_a6,%mm6; \ pand S3_x11,%mm6; \ movq %mm7,out4; \ movq S3_x2,%mm0; \ pxor %mm6,%mm3; \ por S3_x6,%mm6; \ pand %mm1,%mm3; \ por S3_x38,%mm0; \ pxor %mm6,%mm3; \ pxor S3_x13,%mm0; \ movq %mm5,%mm6; \ por S3_a1,%mm3; \ pxor %mm5,%mm0; \ pand S3_x54,%mm6; \ pxor %mm4,%mm3; \ por S3_a1,%mm6; \ pxor out3,%mm3; \ pxor %mm0,%mm6; \ pxor out1,%mm2; \ movq %mm3,out3; \ pxor out2,%mm6; \ movq %mm2,out1; \ movq %mm6,out2#define S4_out1 %mm1#define S4_out2 %mm0#define S4_out3 %mm6#define S4_out4 %mm5#define S4_a2 tmp_at(1)#define S4_a3 tmp_at(2)#define S4_a4 tmp_at(3)#define S4_a6 tmp_at(4)#define S4(out1, out2, out3, out4, extra) \ movq %mm2,%mm6; \ movq %mm3,S4_a4; \ movq %mm0,%mm7; \ movq %mm1,S4_a2; \ por %mm0,%mm6; \ extra; \ pand %mm4,%mm7; \ movq %mm1,%mm3; \ movq %mm5,S4_a6; \ movq %mm2,S4_a3; \ movq %mm4,%mm5; \ pand %mm6,%mm5; \ por %mm2,%mm3; \ pxor pnot,%mm2; \ pxor %mm5,%mm0; \ pxor pnot,%mm0; \ pxor %mm7,%mm6; \ pxor %mm0,%mm3; \ movq %mm1,%mm7; \ pand %mm6,%mm7; \ pxor %mm2,%mm5; \ pxor %mm4,%mm2; \ pand %mm5,%mm0; \ pxor %mm7,%mm4; \ pand %mm1,%mm5; \ por %mm1,%mm2; \ pxor %mm6,%mm5; \ movq S4_a4,%mm1; \ movq %mm0,%mm6; \ pand %mm4,%mm1; \ pxor %mm2,%mm6; \ por S4_a4,%mm6; \ pxor %mm3,%mm1; \ pand S4_a2,%mm4; \ pxor %mm5,%mm6; \ movq S4_a6,%mm3; \ pxor %mm0,%mm4; \ pxor S4_a3,%mm7; \ movq %mm3,%mm0; \ pxor %mm2,%mm7; \ pand %mm6,%mm0; \ movq S4_a4,%mm2; \ por %mm3,%mm6; \ pxor %mm1,%mm0; \ pand %mm2,%mm7; \ pxor pnot,%mm1; \ pxor %mm7,%mm4; \ movq %mm4,%mm5; \ pxor %mm1,%mm4; \ pxor out1,%mm1; \ por %mm4,%mm2; \ pand S4_a2,%mm4; \ pxor %mm6,%mm1; \ pxor %mm0,%mm4; \ pxor out3,%mm6; \ pxor %mm4,%mm2; \ pxor out2,%mm0; \ pand %mm2,%mm3; \ pxor %mm2,%mm6; \ pxor %mm3,%mm5; \ movq %mm1,out1; \ pxor %mm5,%mm6; \ movq %mm0,out2; \ pxor out4,%mm5; \ movq %mm6,out3; \ movq %mm5,out4#define S5_out1 %mm5#define S5_out2 %mm7#define S5_out3 %mm6#define S5_out4 %mm4#define S5_a1 tmp_at(1)#define S5_a2 tmp_at(2)#define S5_a6 tmp_at(3)#define S5_x2 tmp_at(4)#define S5_x4 tmp_at(5)#define S5_x5 tmp_at(6)#define S5_x6 tmp_at(7)#define S5_x7 tmp_at(8)#define S5_x8 tmp_at(9)#define S5_x9 tmp_at(10)#define S5_x13 tmp_at(11)#define S5_x16 tmp_at(12)#define S5_x17 S5_a6#define S5_x21 S5_x7#define S5_x24 S5_x8#define S5_x28 S5_x17#define S5_x38 S5_x9#define S5(out1, out2, out3, out4, extra) \ movq %mm1,S5_a2; \ movq %mm3,%mm6; \ movq %mm2,%mm7; \ pandn %mm2,%mm6; \ pandn %mm0,%mm7; \ movq %mm6,%mm1; \ movq %mm0,S5_a1; \ pxor %mm0,%mm1; \ extra; \ pxor %mm3,%mm0; \ movq %mm1,S5_x2; \ movq %mm5,S5_a6; \ por %mm0,%mm6; \ por %mm7,%mm5; \ movq %mm6,S5_x7; \ pxor %mm5,%mm1; \ movq %mm5,S5_x4; \ pand %mm2,%mm6; \ movq S5_a6,%mm5; \ pxor %mm3,%mm6; \ pandn S5_x7,%mm5; \ movq %mm0,S5_x6; \ movq %mm7,%mm0; \ movq %mm5,S5_x8; \ pxor %mm2,%mm5; \ movq %mm1,S5_x5; \ pxor %mm3,%mm0; \ movq %mm5,S5_x9; \ pandn %mm6,%mm7; \ por S5_a6,%mm0; \ por %mm4,%mm5; \ movq %mm6,S5_x13; \ pxor %mm1,%mm5; \ movq %mm0,S5_x16; \ pxor %mm0,%mm7; \ movq S5_a2,%mm0; \ movq %mm4,%mm1; \ movq %mm7,S5_x17; \ por %mm7,%mm1; \ pand S5_x5,%mm7; \ pxor %mm6,%mm1; \ pandn %mm1,%mm0; \ movq %mm7,%mm6; \ pandn S5_x7,%mm6; \ pxor %mm0,%mm5; \ pxor S5_x9,%mm7; \ movq %mm3,%mm0; \ movq %mm5,S5_x21; \ movq %mm6,%mm5; \ pandn S5_x8,%mm0; \ pandn %mm1,%mm5; \ pxor out3,%mm6; \ pxor %mm2,%mm0; \ movq S5_a1,%mm2; \ movq %mm0,%mm1; \ pxor S5_x9,%mm2; \ pand %mm4,%mm1; \ movq %mm7,S5_x38; \ pxor %mm1,%mm6; \ movq S5_x4,%mm1; \ movq %mm2,%mm7; \ pand S5_x2,%mm7; \ pand %mm3,%mm1; \ pxor S5_x17,%mm1; \ pandn %mm4,%mm7; \ movq %mm2,S5_x24; \ pxor %mm7,%mm1; \ movq out2,%mm7; \ por %mm2,%mm3; \ movq S5_a2,%mm2; \ pxor %mm1,%mm7; \ movq %mm3,S5_x28; \ pandn %mm3,%mm2; \ movq S5_x38,%mm3; \ pxor %mm2,%mm7; \ movq S5_x16,%mm2; \ por %mm4,%mm3; \ por S5_x13,%mm2; \ por %mm5,%mm1; \ pxor out1,%mm5; \ pxor %mm3,%mm2; \ por S5_a2,%mm2; \ movq %mm7,out2; \ pxor S5_x6,%mm1; \ pxor %mm2,%mm6; \ pandn %mm4,%mm1; \ movq S5_x38,%mm2; \ pxor S5_x24,%mm1; \ movq %mm2,%mm3; \ pxor S5_x21,%mm2; \ pxor %mm1,%mm5; \ pand S5_x6,%mm3; \ pandn %mm4,%mm2; \ pand S5_x28,%mm2; \ pxor %mm0,%mm3; \ pxor pnot,%mm6; \ pxor %mm2,%mm3; \ movq S5_x21,%mm4; \ por S5_a2,%mm3; \ movq %mm6,out3; \ pxor out4,%mm4; \ pxor %mm3,%mm5; \ movq %mm4,out4; \ movq %mm5,out1#define S6_out1 %mm0#undef S6_out2#define S6_out3 %mm2#define S6_out4 %mm4#define S6_a1 tmp_at(1)#define S6_a2 tmp_at(2)#define S6_a3 tmp_at(3)#define S6_a4 tmp_at(4)#define S6_x1 tmp_at(5)#define S6_x2 tmp_at(6)#define S6_x5 tmp_at(7)#define S6_x6 tmp_at(8)#define S6_x8 tmp_at(9)#define S6_x15 tmp_at(10)#define S6_x16 tmp_at(11)#define S6(out1, out2, out3, out4, extra) \ movq %mm2,S6_a3; \ extra; \ movq %mm4,%mm6; \ pxor pnot,%mm6; \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -