| ; Don't even think of reading this code |
| ; It was automatically generated by bf586.pl |
| ; Which is a perl program used to generate the x86 assember for |
| ; any of elf, a.out, Win32, or Solaris |
| ; It can be found in SSLeay 0.7.0+ |
| ; eric <eay@cryptsoft.com> |
| ; |
| TITLE bfx86xxxx.asm |
| .386 |
| .model FLAT |
| _TEXT SEGMENT |
| PUBLIC _BF_encrypt |
| EXTRN _des_SPtrans:DWORD |
| _BF_encrypt PROC NEAR |
| push ebp |
| push ebx |
| push esi |
| push edi |
| ; |
| ; Load the 2 words |
| mov eax, DWORD PTR 20[esp] |
| mov ecx, DWORD PTR [eax] |
| mov edx, DWORD PTR 4[eax] |
| ; |
| ; P pointer, s and enc flag |
| mov edi, DWORD PTR 24[esp] |
| xor eax, eax |
| xor ebx, ebx |
| mov ebp, DWORD PTR 28[esp] |
| cmp ebp, 0 |
| je $L000start_decrypt |
| xor ecx, DWORD PTR [edi] |
| ; |
| ; Round 0 |
| ror ecx, 16 |
| mov esi, DWORD PTR 4[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 1 |
| ror edx, 16 |
| mov esi, DWORD PTR 8[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 2 |
| ror ecx, 16 |
| mov esi, DWORD PTR 12[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 3 |
| ror edx, 16 |
| mov esi, DWORD PTR 16[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 4 |
| ror ecx, 16 |
| mov esi, DWORD PTR 20[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 5 |
| ror edx, 16 |
| mov esi, DWORD PTR 24[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 6 |
| ror ecx, 16 |
| mov esi, DWORD PTR 28[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 7 |
| ror edx, 16 |
| mov esi, DWORD PTR 32[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 8 |
| ror ecx, 16 |
| mov esi, DWORD PTR 36[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 9 |
| ror edx, 16 |
| mov esi, DWORD PTR 40[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 10 |
| ror ecx, 16 |
| mov esi, DWORD PTR 44[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 11 |
| ror edx, 16 |
| mov esi, DWORD PTR 48[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 12 |
| ror ecx, 16 |
| mov esi, DWORD PTR 52[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 13 |
| ror edx, 16 |
| mov esi, DWORD PTR 56[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 14 |
| ror ecx, 16 |
| mov esi, DWORD PTR 60[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 15 |
| ror edx, 16 |
| mov esi, DWORD PTR 64[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| xor edx, DWORD PTR 68[edi] |
| mov eax, DWORD PTR 20[esp] |
| mov DWORD PTR [eax],edx |
| mov DWORD PTR 4[eax],ecx |
| pop edi |
| pop esi |
| pop ebx |
| pop ebp |
| ret |
| $L000start_decrypt: |
| xor ecx, DWORD PTR 68[edi] |
| ; |
| ; Round 16 |
| ror ecx, 16 |
| mov esi, DWORD PTR 64[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 15 |
| ror edx, 16 |
| mov esi, DWORD PTR 60[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 14 |
| ror ecx, 16 |
| mov esi, DWORD PTR 56[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 13 |
| ror edx, 16 |
| mov esi, DWORD PTR 52[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 12 |
| ror ecx, 16 |
| mov esi, DWORD PTR 48[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 11 |
| ror edx, 16 |
| mov esi, DWORD PTR 44[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 10 |
| ror ecx, 16 |
| mov esi, DWORD PTR 40[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 9 |
| ror edx, 16 |
| mov esi, DWORD PTR 36[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 8 |
| ror ecx, 16 |
| mov esi, DWORD PTR 32[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 7 |
| ror edx, 16 |
| mov esi, DWORD PTR 28[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 6 |
| ror ecx, 16 |
| mov esi, DWORD PTR 24[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 5 |
| ror edx, 16 |
| mov esi, DWORD PTR 20[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 4 |
| ror ecx, 16 |
| mov esi, DWORD PTR 16[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 3 |
| ror edx, 16 |
| mov esi, DWORD PTR 12[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| ; |
| ; Round 2 |
| ror ecx, 16 |
| mov esi, DWORD PTR 8[edi] |
| mov al, ch |
| mov bl, cl |
| ror ecx, 16 |
| xor edx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, ch |
| mov bl, cl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor edx, esi |
| ; |
| ; Round 1 |
| ror edx, 16 |
| mov esi, DWORD PTR 4[edi] |
| mov al, dh |
| mov bl, dl |
| ror edx, 16 |
| xor ecx, esi |
| mov esi, DWORD PTR 72[eax*4+edi] |
| mov ebp, DWORD PTR 1096[ebx*4+edi] |
| mov al, dh |
| mov bl, dl |
| add esi, ebp |
| mov eax, DWORD PTR 2120[eax*4+edi] |
| xor esi, eax |
| mov ebp, DWORD PTR 3144[ebx*4+edi] |
| add esi, ebp |
| xor eax, eax |
| xor ecx, esi |
| xor edx, DWORD PTR [edi] |
| mov eax, DWORD PTR 20[esp] |
| mov DWORD PTR [eax],edx |
| mov DWORD PTR 4[eax],ecx |
| pop edi |
| pop esi |
| pop ebx |
| pop ebp |
| ret |
| _BF_encrypt ENDP |
| _TEXT ENDS |
| END |