From 3773d138cefa8958a679094281d6b23af6eaf2b9 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Thu, 11 Feb 1999 00:07:39 +0000 Subject: [PATCH] Delete a few unused files in apps, restore CAST WIN32 ASM file to main tree. --- apps/cert.der | Bin 380 -> 0 bytes apps/stuff/pkcs12.der | Bin 1281 -> 0 bytes crypto/cast/asm/.cvsignore | 1 - crypto/cast/asm/c-win32.asm | 953 ++++++++++++++++++++++++++++++++++++ 4 files changed, 953 insertions(+), 1 deletion(-) delete mode 100644 apps/cert.der delete mode 100644 apps/stuff/pkcs12.der create mode 100644 crypto/cast/asm/c-win32.asm diff --git a/apps/cert.der b/apps/cert.der deleted file mode 100644 index 58d9fd89ba7b47321f17d951aa8c59980b0a6fa8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 380 zcmXqLVyrM|VpL;dWHjJpW7XzkW|C!PFt9e{HQ;7r4rO5$W^oDfFf^1hkbrOnLyAg^ zOB8%Efkbd-dR}UgA)f&cM2@w%B(*HnKtY_>(!#*V$k@=>*v!NvN`l|e%)k%~4L~4@ zGUH5blEZy(CoqkGDJN`ic zXRyFjrTqWkG6oQ@ z%BnIl{$~MsjZ2%2k%h6zoQoMbh?pH2>}H&f^zmd2EX+CT`tkDP^?&*}oqK|n?`9RG rZC8|P(a;t+yd^3*w*SrLZxvgn8u)D2_#IFeyx3YysZ?>Qs{AqlmquUui+#Q5K!iSaj({tBc&!c{Xd8YCJjqd7-JcbP=#ljds^<)(V} zvxjoEe=B}0XH~+G%23Qu!eGRp4x|+roEeH3Dj5oZBE<~(3~4}Gfgu1$Rsv}sAe{oF zJsDgW7#J2bG1dWXtul~dO5&u)|p>&YRT$* zjQg%TJLr|X+L0Vxv#UY#+u|J-MW?uvCJVk4Q;a|QA!Od$x%tx@c17nXA9y|O&I#^| z52a;hIZoUzH`U0EOH{O7py)?EtA6!+j#iGkiLm{zJLWhfm~DMGL*H&+(o>T{kx;qw4U=SbuU$*K;IY7{p!e$D zYq1+#|EIDF#bn?3bUV)SO!x`2I^)BlNnZ7_^9`p?VQ!wKU%7Z!_BX+GyTAPT{LrUH zlD&NP)$Whe!pnJ)-Ab^ zb2CqLVQH;RP|=J~xwW3(3&O14-oDEE_SyBUOZ)czXH6)+D7Wy;FR$<1mg*a;J2s!# zKjU@R>~5c**}c8fu77OcS~+)yi}*6PvL|kP(#%)=^|3i3vH9E%&c4P^J4yx0;(qlx zl=H;8&3!jXTN$))JaJJy#f;>YTremvLXD;lPm*x;?;<_%PpmFW#1BRww(I=~) z`xj}c#ohJu$=SR_*>aWD>{98TUAuL+JvgjnsJqhOm!9G3R@X!JvwLd3-f-I1x3jtI zN$lR~`TUCKBF@acX}pzTdR~{=_Y4K*tG~nYLzEtfoK3jz7r>#R`a3E(<;VsH%YtUs z>rSy#iza;*N_lI*&$j=s_rKU+>!*RsbYD37U)&%YReQibO_n?Hut3j~8Ee + ; + TITLE cast-586.asm + .486 +.model FLAT +_TEXT SEGMENT +PUBLIC _CAST_encrypt +EXTERN _CAST_S_table0:DWORD +EXTERN _CAST_S_table1:DWORD +EXTERN _CAST_S_table2:DWORD +EXTERN _CAST_S_table3:DWORD + +_CAST_encrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + ; Get short key flag + mov eax, DWORD PTR 128[ebp] + push eax + xor eax, eax + ; round 0 + mov edx, DWORD PTR [ebp] + mov ecx, DWORD PTR 4[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 1 + mov edx, DWORD PTR 8[ebp] + mov ecx, DWORD PTR 12[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 2 + mov edx, DWORD PTR 16[ebp] + mov ecx, DWORD PTR 20[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 3 + mov edx, DWORD PTR 24[ebp] + mov ecx, DWORD PTR 28[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 4 + mov edx, DWORD PTR 32[ebp] + mov ecx, DWORD PTR 36[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 5 + mov edx, DWORD PTR 40[ebp] + mov ecx, DWORD PTR 44[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 6 + mov edx, DWORD PTR 48[ebp] + mov ecx, DWORD PTR 52[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 7 + mov edx, DWORD PTR 56[ebp] + mov ecx, DWORD PTR 60[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 8 + mov edx, DWORD PTR 64[ebp] + mov ecx, DWORD PTR 68[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 9 + mov edx, DWORD PTR 72[ebp] + mov ecx, DWORD PTR 76[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 10 + mov edx, DWORD PTR 80[ebp] + mov ecx, DWORD PTR 84[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 11 + mov edx, DWORD PTR 88[ebp] + mov ecx, DWORD PTR 92[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; test short key flag + pop edx + or edx, edx + jnz $L000cast_enc_done + ; round 12 + mov edx, DWORD PTR 96[ebp] + mov ecx, DWORD PTR 100[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 13 + mov edx, DWORD PTR 104[ebp] + mov ecx, DWORD PTR 108[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 14 + mov edx, DWORD PTR 112[ebp] + mov ecx, DWORD PTR 116[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 15 + mov edx, DWORD PTR 120[ebp] + mov ecx, DWORD PTR 124[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx +$L000cast_enc_done: + nop + mov eax, DWORD PTR 20[esp] + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_CAST_encrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _CAST_decrypt +EXTERN _CAST_S_table0:DWORD +EXTERN _CAST_S_table1:DWORD +EXTERN _CAST_S_table2:DWORD +EXTERN _CAST_S_table3:DWORD + +_CAST_decrypt PROC NEAR + ; + push ebp + push ebx + mov ebx, DWORD PTR 12[esp] + mov ebp, DWORD PTR 16[esp] + push esi + push edi + ; Load the 2 words + mov edi, DWORD PTR [ebx] + mov esi, DWORD PTR 4[ebx] + ; Get short key flag + mov eax, DWORD PTR 128[ebp] + or eax, eax + jnz $L001cast_dec_skip + xor eax, eax + ; round 15 + mov edx, DWORD PTR 120[ebp] + mov ecx, DWORD PTR 124[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 14 + mov edx, DWORD PTR 112[ebp] + mov ecx, DWORD PTR 116[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 13 + mov edx, DWORD PTR 104[ebp] + mov ecx, DWORD PTR 108[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 12 + mov edx, DWORD PTR 96[ebp] + mov ecx, DWORD PTR 100[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx +$L001cast_dec_skip: + ; round 11 + mov edx, DWORD PTR 88[ebp] + mov ecx, DWORD PTR 92[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 10 + mov edx, DWORD PTR 80[ebp] + mov ecx, DWORD PTR 84[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 9 + mov edx, DWORD PTR 72[ebp] + mov ecx, DWORD PTR 76[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 8 + mov edx, DWORD PTR 64[ebp] + mov ecx, DWORD PTR 68[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 7 + mov edx, DWORD PTR 56[ebp] + mov ecx, DWORD PTR 60[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 6 + mov edx, DWORD PTR 48[ebp] + mov ecx, DWORD PTR 52[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + ; round 5 + mov edx, DWORD PTR 40[ebp] + mov ecx, DWORD PTR 44[ebp] + sub edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor edi, ecx + ; round 4 + mov edx, DWORD PTR 32[ebp] + mov ecx, DWORD PTR 36[ebp] + xor edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor esi, ecx + ; round 3 + mov edx, DWORD PTR 24[ebp] + mov ecx, DWORD PTR 28[ebp] + add edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor edi, ecx + ; round 2 + mov edx, DWORD PTR 16[ebp] + mov ecx, DWORD PTR 20[ebp] + sub edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + sub ecx, ebx + xor esi, ecx + ; round 1 + mov edx, DWORD PTR 8[ebp] + mov ecx, DWORD PTR 12[ebp] + xor edx, esi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + add ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + xor ecx, ebx + xor edi, ecx + ; round 0 + mov edx, DWORD PTR [ebp] + mov ecx, DWORD PTR 4[ebp] + add edx, edi + rol edx, cl + mov ebx, edx + xor ecx, ecx + mov cl, dh + and ebx, 255 + shr edx, 16 + xor eax, eax + mov al, dh + and edx, 255 + mov ecx, DWORD PTR _CAST_S_table0[ecx*4] + mov ebx, DWORD PTR _CAST_S_table1[ebx*4] + xor ecx, ebx + mov ebx, DWORD PTR _CAST_S_table2[eax*4] + sub ecx, ebx + mov ebx, DWORD PTR _CAST_S_table3[edx*4] + add ecx, ebx + xor esi, ecx + nop + mov eax, DWORD PTR 20[esp] + mov DWORD PTR 4[eax],edi + mov DWORD PTR [eax],esi + pop edi + pop esi + pop ebx + pop ebp + ret +_CAST_decrypt ENDP +_TEXT ENDS +_TEXT SEGMENT +PUBLIC _CAST_cbc_encrypt + +_CAST_cbc_encrypt PROC NEAR + ; + push ebp + push ebx + push esi + push edi + mov ebp, DWORD PTR 28[esp] + ; getting iv ptr from parameter 4 + mov ebx, DWORD PTR 36[esp] + mov esi, DWORD PTR [ebx] + mov edi, DWORD PTR 4[ebx] + push edi + push esi + push edi + push esi + mov ebx, esp + mov esi, DWORD PTR 36[esp] + mov edi, DWORD PTR 40[esp] + ; getting encrypt flag from parameter 5 + mov ecx, DWORD PTR 56[esp] + ; get and push parameter 3 + mov eax, DWORD PTR 48[esp] + push eax + push ebx + cmp ecx, 0 + jz $L002decrypt + and ebp, 4294967288 + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + jz $L003encrypt_finish +L004encrypt_loop: + mov ecx, DWORD PTR [esi] + mov edx, DWORD PTR 4[esi] + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L004encrypt_loop +$L003encrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L005finish + xor ecx, ecx + xor edx, edx + mov ebp, DWORD PTR $L006cbc_enc_jmp_table[ebp*4] + jmp ebp +L007ej7: + xor edx, edx + mov dh, BYTE PTR 6[esi] + shl edx, 8 +L008ej6: + mov dh, BYTE PTR 5[esi] +L009ej5: + mov dl, BYTE PTR 4[esi] +L010ej4: + mov ecx, DWORD PTR [esi] + jmp $L011ejend +L012ej3: + mov ch, BYTE PTR 2[esi] + xor ecx, ecx + shl ecx, 8 +L013ej2: + mov ch, BYTE PTR 1[esi] +L014ej1: + mov cl, BYTE PTR [esi] +$L011ejend: + xor eax, ecx + xor ebx, edx + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_encrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov DWORD PTR [edi],eax + mov DWORD PTR 4[edi],ebx + jmp $L005finish +$L002decrypt: + and ebp, 4294967288 + mov eax, DWORD PTR 16[esp] + mov ebx, DWORD PTR 20[esp] + jz $L015decrypt_finish +L016decrypt_loop: + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + mov DWORD PTR [edi],ecx + mov DWORD PTR 4[edi],edx + mov DWORD PTR 16[esp],eax + mov DWORD PTR 20[esp],ebx + add esi, 8 + add edi, 8 + sub ebp, 8 + jnz L016decrypt_loop +$L015decrypt_finish: + mov ebp, DWORD PTR 52[esp] + and ebp, 7 + jz $L005finish + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] + bswap eax + bswap ebx + mov DWORD PTR 8[esp],eax + mov DWORD PTR 12[esp],ebx + call _CAST_decrypt + mov eax, DWORD PTR 8[esp] + mov ebx, DWORD PTR 12[esp] + bswap eax + bswap ebx + mov ecx, DWORD PTR 16[esp] + mov edx, DWORD PTR 20[esp] + xor ecx, eax + xor edx, ebx + mov eax, DWORD PTR [esi] + mov ebx, DWORD PTR 4[esi] +L017dj7: + ror edx, 16 + mov BYTE PTR 6[edi],dl + shr edx, 16 +L018dj6: + mov BYTE PTR 5[edi],dh +L019dj5: + mov BYTE PTR 4[edi],dl +L020dj4: + mov DWORD PTR [edi],ecx + jmp $L021djend +L022dj3: + ror ecx, 16 + mov BYTE PTR 2[edi],cl + shl ecx, 16 +L023dj2: + mov BYTE PTR 1[esi],ch +L024dj1: + mov BYTE PTR [esi], cl +$L021djend: + jmp $L005finish +$L005finish: + mov ecx, DWORD PTR 60[esp] + add esp, 24 + mov DWORD PTR [ecx],eax + mov DWORD PTR 4[ecx],ebx + pop edi + pop esi + pop ebx + pop ebp + ret +$L006cbc_enc_jmp_table: + DD 0 + DD L014ej1 + DD L013ej2 + DD L012ej3 + DD L010ej4 + DD L009ej5 + DD L008ej6 + DD L007ej7 +L025cbc_dec_jmp_table: + DD 0 + DD L024dj1 + DD L023dj2 + DD L022dj3 + DD L020dj4 + DD L019dj5 + DD L018dj6 + DD L017dj7 +_CAST_cbc_encrypt ENDP +_TEXT ENDS +END -- 2.25.1