⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 twofish.inc

📁 The dinamyc link library that contains an implementation of SHA1, SHA512, CRC32, CRC32b, Adler32, Tw
💻 INC
📖 第 1 页 / 共 2 页
字号:
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$400+ecx*4]
     mov edx,ebx
     add edx,edx
     mov [twofish_sbox+4+edx*4],ecx
     xor ecx,ecx
     mov cl,[ebp+ebx+var_15C+1]
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$400+ecx*4]
     inc edx
     mov [twofish_sbox+8+edx*4],ecx
     add ebx,2
     cmp ebx,256
     jb @r
     mov ecx,[ebp+var_54]
     shr ecx,16
     and cl,255
     mov edx,twofish_p8x8
     lea eax,[ebp+var_15C]
     call __xor256
     mov esi,[ebp+var_5C]
     shr esi,16
     and esi,255
     mov eax,[ebp+var_58]
     shr eax,16
     and eax,255
     xor ebx,ebx
@@:  xor ecx,ecx
     mov cl,[ebp+ebx+var_15C]
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$800+ecx*4]
     mov edx,ebx
     add edx,edx
     mov [twofish_sbox+$800+edx*4],ecx
     xor ecx,ecx
     mov cl,[ebp+ebx+var_15C+1]
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$800+ecx*4]
     mov [twofish_sbox+$808+edx*4],ecx
     add ebx,2
     cmp ebx,256
     jb @r
     mov ecx,[ebp+var_54]
     shr ecx,24
     mov edx,twofish_p8x8
     lea eax,[ebp+var_15C]
     call __xor256
     mov esi,[ebp+var_5C]
     shr esi,24
     mov eax,[ebp+var_58]
     shr eax,24
     xor ebx,ebx
@@:  xor ecx,ecx
     mov cl,[ebp+ebx+var_15C]
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$C00+ecx*4]
     mov edx,ebx
     add edx,edx
     mov [twofish_sbox+$804+edx*4],ecx
     xor ecx,ecx
     mov cl,[ebp+ebx+var_15C+1]
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$C00+ecx*4]
     inc edx
     mov [twofish_sbox+$808+edx*4],ecx
     add ebx,2
     cmp ebx,256
     jb @r
     jmp .init_end
 .keysize256:
     mov cl,[ebp+var_50]
     and cl,255
     mov edx,twofish_p8x8+256
     lea eax,[ebp+var_25C]
     call __xor256
     xor ebx,ebx
@@:  xor eax,eax
     mov al,[ebp+ebx+var_25C]
     mov al,[twofish_p8x8+256+eax]
     mov [ebp+ebx+var_15C],al
     xor eax,eax
     mov al,[ebp+ebx+var_25C+1]
     mov al,[twofish_p8x8+256+eax]
     mov [ebp+ebx+var_15C+1],al
     add ebx,2
     cmp ebx,256
     jb @r
     mov cl,[ebp+var_54]
     and cl,255
     lea edx,[ebp+var_15C]
     lea eax,[ebp+var_15C]
     call __xor256
     mov esi,[ebp+var_5C]
     and esi,255
     mov eax,[ebp+var_58]
     and eax,255
     xor ebx,ebx
@@:  xor ecx,ecx
     mov cl,[ebp+ebx+var_15C]
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+ecx*4]
     mov edx,ebx
     add edx,edx
     mov [twofish_sbox+edx*4],ecx
     xor ecx,ecx
     mov cl,[ebp+ebx+var_15C+1]
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+ecx*4]
     mov [twofish_sbox+8+edx*4],ecx
     add ebx,2
     cmp ebx,256
     jb @r
     mov ecx,[ebp+var_50]
     shr ecx,8
     and cl,255
     mov edx,twofish_p8x8
     lea eax,[ebp+var_25C]
     call __xor256
     xor ebx,ebx
@@:  xor eax,eax
     mov al,[ebp+ebx+var_25C]
     mov al,[twofish_p8x8+256+eax]
     mov [ebp+ebx+var_15C],al
     xor eax,eax
     mov al,[ebp+ebx+var_25C+1]
     mov al,[twofish_p8x8+256+eax]
     mov [ebp+ebx+var_15C+1],al
     add ebx,2
     cmp ebx,256
     jb @r
     mov ecx,[ebp+var_54]
     shr ecx,8
     and cl,255
     lea edx,[ebp+var_15C]
     lea eax,[ebp+var_15C]
     call __xor256
     mov esi,[ebp+var_5C]
     shr esi,8
     and esi,255
     mov eax,[ebp+var_58]
     shr eax,8
     and eax,255
     xor ebx,ebx
@@:  xor ecx,ecx
     mov cl,[ebp+ebx+var_15C]
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$400+ecx*4]
     mov edx,ebx
     add edx,edx
     mov [twofish_sbox+4+edx*4],ecx
     xor ecx,ecx
     mov cl,[ebp+ebx+var_15C+1]
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$400+ecx*4]
     inc edx
     mov [twofish_sbox+8+edx*4],ecx
     add ebx,2
     cmp ebx,256
     jb @r
     mov ecx,[ebp+var_50]
     shr ecx,16
     and cl,255
     mov edx,twofish_p8x8
     lea eax,[ebp+var_25C]
     call __xor256
     xor ebx,ebx
@@:  xor eax,eax
     mov al,[ebp+ebx+var_25C]
     mov al,[twofish_p8x8+eax]
     mov [ebp+ebx+var_15C],al
     xor eax,eax
     mov al,[ebp+ebx+var_25C+1]
     mov al,[twofish_p8x8+eax]
     mov [ebp+ebx+var_15C+1],al
     add ebx,2
     cmp ebx,256
     jb @r
     mov ecx,[ebp+var_54]
     shr ecx,16
     and cl,255
     lea edx,[ebp+var_15C]
     lea eax,[ebp+var_15C]
     call __xor256
     mov esi,[ebp+var_5C]
     shr esi,16
     and esi,255
     mov eax,[ebp+var_58]
     shr eax,16
     and eax,255
     xor ebx,ebx
@@:  xor ecx,ecx
     mov cl,[ebp+ebx+var_15C]
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$800+ecx*4]
     mov edx,ebx
     add edx,edx
     mov [twofish_sbox+$800+edx*4],ecx
     xor ecx,ecx
     mov cl,[ebp+ebx+var_15C+1]
     movzx ecx,byte [twofish_p8x8+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$800+ecx*4]
     mov [twofish_sbox+$808+edx*4],ecx
     add ebx,2
     cmp ebx,256
     jb @r
     mov ecx,[ebp+var_50]
     shr ecx,24
     mov edx,twofish_p8x8+256
     lea eax,[ebp+var_25C]
     call __xor256
     xor ebx,ebx
@@:  xor eax,eax
     mov al,[ebp+ebx+var_25C]
     mov al,[twofish_p8x8+eax]
     mov [ebp+ebx+var_15C],al
     xor eax,eax
     mov al,[ebp+ebx+var_25C+1]
     mov al,[twofish_p8x8+eax]
     mov [ebp+ebx+var_15C+1],al
     add ebx,2
     cmp ebx,256
     jb @r
     mov ecx,[ebp+var_54]
     shr ecx,24
     lea edx,[ebp+var_15C]
     lea eax,[ebp+var_15C]
     call __xor256
     mov esi,[ebp+var_5C]
     shr esi,24
     mov eax,[ebp+var_58]
     shr eax,24
     xor ebx,ebx
@@:  xor ecx,ecx
     mov cl,[ebp+ebx+var_15C]
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$C00+ecx*4]
     mov edx,ebx
     add edx,edx
     mov [twofish_sbox+$804+edx*4],ecx
     xor ecx,ecx
     mov cl,[ebp+ebx+var_15C+1]
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,eax
     movzx ecx,byte [twofish_p8x8+256+ecx]
     xor ecx,esi
     mov ecx,[twofish_mds+$C00+ecx*4]
     inc edx
     mov [twofish_sbox+$808+edx*4],ecx
     add ebx,2
     cmp ebx,256
     jb @r
.init_end:
     pop edi
     pop esi
     pop ebx
     mov esp,ebp
     pop ebp
     retn 8
endp

align 4
proc Twofish_EncryptBlock uses ebx esi edi,Block:PBLOCK128
     locals
       t dd ?
       x _BLOCK128
     endl
     lea eax,[x]
     mov edx,twofish_sbox
     mov ecx,[Block]
     mov ecx,[ecx+_BLOCK128.a]
     xor ecx,[twofish_subkeys]
     mov [eax+_BLOCK128.a],ecx
     mov ecx,[Block]
     mov ecx,[ecx+_BLOCK128.b]
     xor ecx,[twofish_subkeys+4]
     mov [eax+_BLOCK128.b],ecx
     mov ecx,[Block]
     mov ecx,[ecx+_BLOCK128.c]
     xor ecx,[twofish_subkeys+8]
     mov [eax+_BLOCK128.c],ecx
     mov ecx,[Block]
     mov ecx,[ecx+_BLOCK128.d]
     xor ecx,[twofish_subkeys+12]
     mov [eax+_BLOCK128.d],ecx
     xor ecx,ecx
@@:  mov ebx,[eax+_BLOCK128.a]
     mov esi,ebx
     add esi,esi
     and esi,510
     mov esi,[edx+esi*4]
     mov edi,ebx
     shr edi,7
     and edi,510
     xor esi,[edx+edi*4+4]
     mov edi,ebx
     shr edi,15
     and edi,510
     xor esi,[edx+edi*4+$800]
     shr ebx,23
     and ebx,510
     xor esi,[edx+ebx*4+$804]
     mov ebx,esi
     mov esi,[eax+_BLOCK128.b]
     shr esi,23
     and esi,510
     mov esi,[edx+esi*4]
     mov edi,[eax+_BLOCK128.b]
     add edi,edi
     and edi,510
     xor esi,[edx+edi*4+4]
     mov edi,[eax+_BLOCK128.b]
     shr edi,7
     and edi,510
     xor esi,[edx+edi*4+$800]
     mov edi,[eax+_BLOCK128.b]
     shr edi,15
     and edi,510
     xor esi,[edx+edi*4+$804]
     mov [t],esi
     mov esi,[eax+_BLOCK128.d]
     add esi,esi
     mov edi,[eax+_BLOCK128.d]
     shr edi,31
     or esi,edi
     mov [eax+_BLOCK128.d],esi
     mov esi,[t]
     add esi,ebx
     mov edi,ecx
     add edi,edi
     add edi,8
     add esi,[twofish_subkeys+edi*4]
     xor [eax+_BLOCK128.c],esi
     mov esi,[t]
     add esi,esi
     add ebx,esi
     mov esi,ecx
     add esi,esi
     add esi,8
     add ebx,[twofish_subkeys+4+esi*4]
     xor [eax+_BLOCK128.d],ebx
     mov ebx,[eax+_BLOCK128.c]
     shr ebx,1
     mov esi,[eax+_BLOCK128.c]
     shl esi,31
     or ebx,esi
     mov [eax+_BLOCK128.c],ebx
     mov esi,ebx
     add esi,esi
     and esi,510
     mov esi,[edx+esi*4]
     mov edi,ebx
     shr edi,7
     and edi,510
     xor esi,[edx+edi*4+4]
     mov edi,ebx
     shr edi,15
     and edi,510
     xor esi,[edx+edi*4+$800]
     shr ebx,23
     and ebx,510
     xor esi,[edx+ebx*4+$804]
     mov ebx,esi
     mov esi,[eax+_BLOCK128.d]
     shr esi,23
     and esi,510
     mov esi,[edx+esi*4]
     mov edi,[eax+_BLOCK128.d]
     add edi,edi
     and edi,510
     xor esi,[edx+edi*4+4]
     mov edi,[eax+_BLOCK128.d]
     shr edi,7
     and edi,510
     xor esi,[edx+edi*4+$800]
     mov edi,[eax+_BLOCK128.d]
     shr edi,15
     and edi,510
     xor esi,[edx+edi*4+$804]
     mov [t],esi
     mov esi,[eax+_BLOCK128.b]
     add esi,esi
     mov edi,[eax+_BLOCK128.b]
     shr edi,31
     or esi,edi
     mov [eax+_BLOCK128.b],esi
     mov esi,[t]
     add esi,ebx
     lea edi,[ecx+1]
     add edi,edi
     add edi,8
     add esi,[twofish_subkeys+edi*4]
     xor [eax+_BLOCK128.a],esi
     mov esi,[t]
     add esi,esi
     add ebx,esi
     lea esi,[ecx+1]
     add esi,esi
     add esi,8
     add ebx,[twofish_subkeys+4+esi*4]
     xor [eax+_BLOCK128.b],ebx
     mov ebx,[eax+_BLOCK128.a]
     mov esi,ebx
     shr esi,1
     shl ebx,31
     or esi,ebx
     mov [eax+_BLOCK128.a],esi
     add ecx,2
     cmp ecx,14
     jbe @r
     mov edx,[eax+_BLOCK128.c]
     xor edx,[twofish_subkeys+16]
     mov ecx,[Block]
     mov [ecx+_BLOCK128.a],edx
     mov edx,[eax+_BLOCK128.d]
     xor edx,[twofish_subkeys+20]
     mov ecx,[Block]
     mov [ecx+_BLOCK128.b],edx
     mov edx,[eax+_BLOCK128.a]
     xor edx,[twofish_subkeys+24]
     mov ecx,[Block]
     mov [ecx+_BLOCK128.c],edx
     mov eax,[eax+_BLOCK128.b]
     xor eax,[twofish_subkeys+28]
     mov edx,[Block]
     mov [edx+_BLOCK128.d],eax
     ret
endp

align 4
proc Twofish_DecryptBlock uses ebx esi edi,Block:PBLOCK128
     locals
       t dd ?
       x _BLOCK128
     endl
     lea eax,[x]
     mov edx,twofish_sbox
     mov ecx,[Block]
     mov ecx,[ecx+_BLOCK128.a]
     xor ecx,[twofish_subkeys+16]
     mov [eax+_BLOCK128.c],ecx
     mov ecx,[Block]
     mov ecx,[ecx+_BLOCK128.b]
     xor ecx,[twofish_subkeys+20]
     mov [eax+_BLOCK128.d],ecx
     mov ecx,[Block]
     mov ecx,[ecx+_BLOCK128.c]
     xor ecx,[twofish_subkeys+24]
     mov [eax+_BLOCK128.a],ecx
     mov ecx,[Block]
     mov ecx,[ecx+_BLOCK128.d]
     xor ecx,[twofish_subkeys+28]
     mov [eax+_BLOCK128.b],ecx
     mov ecx,14
@@:  mov ebx,[eax+_BLOCK128.c]
     mov esi,ebx
     add esi,esi
     and esi,510
     mov esi,[edx+esi*4]
     mov edi,ebx
     shr edi,7
     and edi,510
     xor esi,[edx+edi*4+4]
     mov edi,ebx
     shr edi,15
     and edi,510
     xor esi,[edx+edi*4+800h]
     shr ebx,23
     and ebx,510
     xor esi,[edx+ebx*4+804h]
     mov ebx,esi
     mov esi,[eax+_BLOCK128.d]
     shr esi,23
     and esi,510
     mov esi,[edx+esi*4]
     mov edi,[eax+_BLOCK128.d]
     add edi,edi
     and edi,510
     xor esi,[edx+edi*4+4]
     mov edi,[eax+_BLOCK128.d]
     shr edi,7
     and edi,510
     xor esi,[edx+edi*4+800h]
     mov edi,[eax+_BLOCK128.d]
     shr edi,15
     and edi,510
     xor esi,[edx+edi*4+804h]
     mov [t],esi
     mov esi,[eax+_BLOCK128.a]
     add esi,esi
     mov edi,[eax+_BLOCK128.a]
     shr edi,31
     or esi,edi
     mov [eax+_BLOCK128.a],esi
     mov esi,[t]
     add esi,ebx
     lea edi,[ecx+1]
     add edi,edi
     add edi,8
     add esi,[twofish_subkeys+edi*4]
     xor [eax+_BLOCK128.a],esi
     mov esi,[t]
     add esi,esi
     add ebx,esi
     lea esi,[ecx+1]
     add esi,esi
     add esi,8
     add ebx,[twofish_subkeys+4+esi*4]
     xor [eax+_BLOCK128.b],ebx
     mov ebx,[eax+_BLOCK128.b]
     mov esi,ebx
     shr esi,1
     shl ebx,31
     or esi,ebx
     mov [eax+_BLOCK128.b],esi
     mov ebx,[eax+_BLOCK128.a]
     mov esi,ebx
     add esi,esi
     and esi,510
     mov esi,[edx+esi*4]
     mov edi,ebx
     shr edi,7
     and edi,510
     xor esi,[edx+edi*4+4]
     mov edi,ebx
     shr edi,15
     and edi,510
     xor esi,[edx+edi*4+$800]
     shr ebx,23
     and ebx,510
     xor esi,[edx+ebx*4+$804]
     mov ebx,esi
     mov esi,[eax+_BLOCK128.b]
     shr esi,23
     and esi,510
     mov esi,[edx+esi*4]
     mov edi,[eax+_BLOCK128.b]
     add edi,edi
     and edi,510
     xor esi,[edx+edi*4+4]
     mov edi,[eax+_BLOCK128.b]
     shr edi,7
     and edi,510
     xor esi,[edx+edi*4+$800]
     mov edi,[eax+_BLOCK128.b]
     shr edi,15
     and edi,510
     xor esi,[edx+edi*4+$804]
     mov [t],esi
     mov esi,[eax+_BLOCK128.c]
     add esi,esi
     mov edi,[eax+_BLOCK128.c]
     shr edi,31
     or esi,edi
     mov [eax+_BLOCK128.c],esi
     mov esi,[t]
     add esi,ebx
     mov edi,ecx
     add edi,edi
     add edi,8
     add esi,[twofish_subkeys+edi*4]
     xor [eax+_BLOCK128.c],esi
     mov esi,[t]
     add esi,esi
     add ebx,esi
     mov esi,ecx
     add esi,esi
     add esi,8
     add ebx,[twofish_subkeys+4+esi*4]
     xor [eax+_BLOCK128.d],ebx
     mov ebx,[eax+_BLOCK128.d]
     mov esi,ebx
     shr esi,1
     shl ebx,31
     or esi,ebx
     mov [eax+_BLOCK128.d],esi
     sub ecx,2
     test ecx,ecx
     jge @r
     mov edx,[eax+_BLOCK128.a]
     xor edx,[twofish_subkeys]
     mov ecx,[Block]
     mov [ecx+_BLOCK128.a],edx
     mov edx,[eax+_BLOCK128.b]
     xor edx,[twofish_subkeys+4]
     mov ecx,[Block]
     mov [ecx+_BLOCK128.b],edx
     mov edx,[eax+_BLOCK128.c]
     xor edx,[twofish_subkeys+8]
     mov ecx,[Block]
     mov [ecx+_BLOCK128.c],edx
     mov eax,[eax+_BLOCK128.d]
     xor eax,[twofish_subkeys+12]
     mov edx,[Block]
     mov [edx+_BLOCK128.d],eax
     ret
endp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -