Last active
August 29, 2015 14:07
-
-
Save axper/47f747fd049351204616 to your computer and use it in GitHub Desktop.
rsa implementation in nasm (decompiled from https://github.com/pantaloons/RSA)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global modpow | |
global jacobi | |
global solovayPrime | |
global probablePrime | |
global randPrime | |
global gcd | |
global randExponent | |
global inverse | |
global readFile | |
global encode | |
global decode | |
global encodeMessage | |
global decodeMessage | |
global main | |
extern free | |
extern fclose | |
extern fopen | |
extern puts | |
extern getchar | |
extern srand | |
extern time | |
extern putchar | |
extern printf | |
extern fread | |
extern memcpy | |
extern realloc | |
extern malloc | |
extern rand | |
extern __moddi3 | |
SECTION .text align=1 | |
modpow: | |
push ebp | |
mov ebp, esp | |
push edi | |
push esi | |
push ebx | |
sub esp, 60 | |
mov eax, dword [ebp+8H] | |
mov dword [ebp-30H], eax | |
mov eax, dword [ebp+0CH] | |
mov dword [ebp-2CH], eax | |
mov eax, dword [ebp+10H] | |
mov dword [ebp-38H], eax | |
mov eax, dword [ebp+14H] | |
mov dword [ebp-34H], eax | |
mov dword [ebp-1CH], 1 | |
jmp L_003 | |
L_001: mov eax, dword [ebp-38H] | |
and eax, 01H | |
mov ebx, eax | |
mov eax, dword [ebp-34H] | |
and eax, 00H | |
mov esi, eax | |
mov eax, esi | |
or eax, ebx | |
test eax, eax | |
jz L_002 | |
mov eax, dword [ebp-1CH] | |
cdq | |
mov ecx, dword [ebp-30H] | |
mov edi, ecx | |
imul edi, edx | |
mov ecx, dword [ebp-2CH] | |
imul ecx, eax | |
add ecx, edi | |
mul dword [ebp-30H] | |
add ecx, edx | |
mov edx, ecx | |
mov ecx, dword [ebp+18H] | |
mov dword [ebp-40H], ecx | |
mov edi, ecx | |
sar edi, 31 | |
mov dword [ebp-3CH], edi | |
push dword [ebp-3CH] | |
push dword [ebp-40H] | |
push edx | |
push eax | |
call __moddi3 | |
add esp, 16 | |
mov dword [ebp-1CH], eax | |
L_002: mov eax, dword [ebp-38H] | |
mov edx, dword [ebp-34H] | |
shrd eax, edx, 1 | |
sar edx, 1 | |
mov dword [ebp-38H], eax | |
mov dword [ebp-34H], edx | |
mov eax, dword [ebp-2CH] | |
imul eax, dword [ebp-30H] | |
mov edx, eax | |
mov eax, dword [ebp-2CH] | |
imul eax, dword [ebp-30H] | |
lea ecx, [edx+eax] | |
mov eax, dword [ebp-30H] | |
mul dword [ebp-30H] | |
add ecx, edx | |
mov edx, ecx | |
mov ecx, dword [ebp+18H] | |
mov dword [ebp-40H], ecx | |
mov edi, ecx | |
sar edi, 31 | |
mov dword [ebp-3CH], edi | |
push dword [ebp-3CH] | |
push dword [ebp-40H] | |
push edx | |
push eax | |
call __moddi3 | |
add esp, 16 | |
mov dword [ebp-30H], eax | |
mov dword [ebp-2CH], edx | |
L_003: cmp dword [ebp-34H], 0 | |
jg L_001 | |
cmp dword [ebp-34H], 0 | |
js L_004 | |
cmp dword [ebp-38H], 0 | |
ja L_001 | |
L_004: mov eax, dword [ebp-1CH] | |
lea esp, [ebp-0CH] | |
pop ebx | |
pop esi | |
pop edi | |
pop ebp | |
ret | |
jacobi: | |
push ebp | |
mov ebp, esp | |
sub esp, 16 | |
mov dword [ebp-8H], 1 | |
jmp L_014 | |
L_005: mov eax, dword [ebp+8H] | |
cdq | |
idiv dword [ebp+0CH] | |
mov dword [ebp+8H], edx | |
cmp dword [ebp+8H], 1 | |
jle L_015 | |
mov eax, dword [ebp+8H] | |
cmp eax, dword [ebp+0CH] | |
je L_015 | |
mov dword [ebp-4H], 0 | |
jmp L_007 | |
L_006: mov eax, dword [ebp+8H] | |
mov edx, eax | |
shr edx, 31 | |
add eax, edx | |
sar eax, 1 | |
mov dword [ebp+8H], eax | |
L_007: mov eax, dword [ebp+8H] | |
and eax, 01H | |
test eax, eax | |
jnz L_008 | |
add dword [ebp-4H], 1 | |
cmp dword [ebp-4H], 0 | |
jnz L_006 | |
L_008: cmp dword [ebp-4H], 0 | |
jle L_012 | |
mov eax, dword [ebp-4H] | |
cdq | |
shr edx, 31 | |
add eax, edx | |
and eax, 01H | |
sub eax, edx | |
cmp eax, 1 | |
jnz L_012 | |
mov eax, dword [ebp+0CH] | |
cdq | |
shr edx, 29 | |
add eax, edx | |
and eax, 07H | |
sub eax, edx | |
cmp eax, 1 | |
jz L_009 | |
mov eax, dword [ebp+0CH] | |
cdq | |
shr edx, 29 | |
add eax, edx | |
and eax, 07H | |
sub eax, edx | |
cmp eax, 7 | |
jnz L_010 | |
L_009: mov eax, 1 | |
jmp L_011 | |
L_010: mov eax, 0 | |
L_011: add eax, eax | |
lea edx, [eax-1H] | |
mov eax, dword [ebp-8H] | |
imul eax, edx | |
mov dword [ebp-8H], eax | |
L_012: cmp dword [ebp+8H], 1 | |
jle L_015 | |
mov eax, dword [ebp+8H] | |
cmp eax, dword [ebp+0CH] | |
jz L_015 | |
mov eax, dword [ebp+0CH] | |
cdq | |
shr edx, 30 | |
add eax, edx | |
and eax, 03H | |
sub eax, edx | |
cmp eax, 1 | |
jz L_013 | |
mov eax, dword [ebp+8H] | |
cdq | |
shr edx, 30 | |
add eax, edx | |
and eax, 03H | |
sub eax, edx | |
cmp eax, 1 | |
jz L_013 | |
neg dword [ebp-8H] | |
L_013: mov eax, dword [ebp+8H] | |
mov dword [ebp-0CH], eax | |
mov eax, dword [ebp+0CH] | |
mov dword [ebp+8H], eax | |
mov eax, dword [ebp-0CH] | |
mov dword [ebp+0CH], eax | |
L_014: cmp dword [ebp+8H], 1 | |
jle L_015 | |
mov eax, dword [ebp+8H] | |
cmp eax, dword [ebp+0CH] | |
jne L_005 | |
L_015: cmp dword [ebp+8H], 0 | |
jnz L_016 | |
mov eax, 0 | |
jmp L_018 | |
L_016: cmp dword [ebp+8H], 1 | |
jnz L_017 | |
mov eax, dword [ebp-8H] | |
jmp L_018 | |
L_017: mov eax, 0 | |
L_018: leave | |
ret | |
solovayPrime: | |
push ebp | |
mov ebp, esp | |
push ebx | |
sub esp, 20 | |
push dword [ebp+0CH] | |
push dword [ebp+8H] | |
call jacobi | |
add esp, 8 | |
mov dword [ebp-0CH], eax | |
cmp dword [ebp-0CH], -1 | |
jnz L_019 | |
mov eax, dword [ebp+0CH] | |
sub eax, 1 | |
mov dword [ebp-0CH], eax | |
L_019: cmp dword [ebp-0CH], 0 | |
jz L_020 | |
mov eax, dword [ebp+0CH] | |
sub eax, 1 | |
mov edx, eax | |
shr edx, 31 | |
add eax, edx | |
sar eax, 1 | |
mov ecx, eax | |
mov ebx, eax | |
sar ebx, 31 | |
mov eax, dword [ebp+8H] | |
cdq | |
sub esp, 12 | |
push dword [ebp+0CH] | |
push ebx | |
push ecx | |
push edx | |
push eax | |
call modpow | |
add esp, 32 | |
cmp eax, dword [ebp-0CH] | |
jnz L_020 | |
mov eax, 1 | |
jmp L_021 | |
L_020: mov eax, 0 | |
L_021: mov ebx, dword [ebp-4H] | |
leave | |
ret | |
probablePrime: | |
push ebp | |
mov ebp, esp | |
sub esp, 8 | |
cmp dword [ebp+8H], 2 | |
jnz L_022 | |
mov eax, 1 | |
jmp L_027 | |
L_022: mov eax, dword [ebp+8H] | |
and eax, 01H | |
test eax, eax | |
jz L_023 | |
cmp dword [ebp+8H], 1 | |
jnz L_024 | |
L_023: mov eax, 0 | |
jmp L_027 | |
L_024: jmp L_026 | |
L_025: call rand | |
mov edx, eax | |
mov eax, dword [ebp+8H] | |
lea ecx, [eax-2H] | |
mov eax, edx | |
cdq | |
idiv ecx | |
mov eax, edx | |
add eax, 2 | |
sub esp, 8 | |
push dword [ebp+8H] | |
push eax | |
call solovayPrime | |
add esp, 16 | |
test eax, eax | |
jnz L_026 | |
mov eax, 0 | |
jmp L_027 | |
L_026: mov eax, dword [ebp+0CH] | |
lea edx, [eax-1H] | |
mov dword [ebp+0CH], edx | |
test eax, eax | |
jg L_025 | |
mov eax, 1 | |
L_027: leave | |
ret | |
randPrime: | |
push ebp | |
mov ebp, esp | |
sub esp, 24 | |
call rand | |
cdq | |
idiv dword [ebp+8H] | |
mov dword [ebp-0CH], edx | |
mov eax, dword [ebp+8H] | |
cdq | |
shr edx, 31 | |
add eax, edx | |
and eax, 01H | |
sub eax, edx | |
add dword [ebp+8H], eax | |
mov eax, dword [ebp-0CH] | |
cdq | |
shr edx, 31 | |
add eax, edx | |
and eax, 01H | |
sub eax, edx | |
mov edx, 1 | |
sub edx, eax | |
mov eax, edx | |
add dword [ebp-0CH], eax | |
L_028: sub esp, 8 | |
push 5 | |
push dword [ebp-0CH] | |
call probablePrime | |
add esp, 16 | |
test eax, eax | |
jz L_029 | |
mov eax, dword [ebp-0CH] | |
jmp L_030 | |
L_029: mov eax, dword [ebp-0CH] | |
add eax, 2 | |
cdq | |
idiv dword [ebp+8H] | |
mov dword [ebp-0CH], edx | |
jmp L_028 | |
L_030: | |
leave | |
ret | |
gcd: | |
push ebp | |
mov ebp, esp | |
sub esp, 16 | |
jmp L_032 | |
L_031: mov eax, dword [ebp+0CH] | |
mov dword [ebp-4H], eax | |
mov eax, dword [ebp+8H] | |
cdq | |
idiv dword [ebp+0CH] | |
mov dword [ebp+0CH], edx | |
mov eax, dword [ebp-4H] | |
mov dword [ebp+8H], eax | |
L_032: cmp dword [ebp+0CH], 0 | |
jnz L_031 | |
mov eax, dword [ebp+8H] | |
leave | |
ret | |
randExponent: | |
push ebp | |
mov ebp, esp | |
sub esp, 24 | |
call rand | |
cdq | |
idiv dword [ebp+0CH] | |
mov dword [ebp-0CH], edx | |
L_033: sub esp, 8 | |
push dword [ebp+8H] | |
push dword [ebp-0CH] | |
call gcd | |
add esp, 16 | |
cmp eax, 1 | |
jnz L_034 | |
mov eax, dword [ebp-0CH] | |
jmp L_036 | |
L_034: mov eax, dword [ebp-0CH] | |
add eax, 1 | |
cdq | |
idiv dword [ebp+0CH] | |
mov dword [ebp-0CH], edx | |
cmp dword [ebp-0CH], 2 | |
jg L_035 | |
mov dword [ebp-0CH], 3 | |
L_035: jmp L_033 | |
L_036: | |
leave | |
ret | |
inverse: | |
push ebp | |
mov ebp, esp | |
sub esp, 32 | |
mov eax, dword [ebp+8H] | |
mov dword [ebp-4H], eax | |
mov eax, dword [ebp+0CH] | |
mov dword [ebp-8H], eax | |
mov dword [ebp-0CH], 0 | |
mov dword [ebp-10H], 1 | |
mov dword [ebp-14H], 1 | |
mov dword [ebp-18H], 0 | |
jmp L_038 | |
L_037: mov eax, dword [ebp-4H] | |
cdq | |
idiv dword [ebp-8H] | |
mov dword [ebp-1CH], eax | |
mov eax, dword [ebp-4H] | |
cdq | |
idiv dword [ebp-8H] | |
mov dword [ebp-20H], edx | |
mov eax, dword [ebp-8H] | |
mov dword [ebp-4H], eax | |
mov eax, dword [ebp-20H] | |
mov dword [ebp-8H], eax | |
mov eax, dword [ebp-0CH] | |
mov dword [ebp-20H], eax | |
mov eax, dword [ebp-1CH] | |
imul eax, dword [ebp-0CH] | |
mov edx, dword [ebp-14H] | |
sub edx, eax | |
mov eax, edx | |
mov dword [ebp-0CH], eax | |
mov eax, dword [ebp-20H] | |
mov dword [ebp-14H], eax | |
mov eax, dword [ebp-10H] | |
mov dword [ebp-20H], eax | |
mov eax, dword [ebp-1CH] | |
imul eax, dword [ebp-10H] | |
mov edx, dword [ebp-18H] | |
sub edx, eax | |
mov eax, edx | |
mov dword [ebp-10H], eax | |
mov eax, dword [ebp-20H] | |
mov dword [ebp-18H], eax | |
L_038: cmp dword [ebp-8H], 0 | |
jnz L_037 | |
cmp dword [ebp-14H], 0 | |
jns L_039 | |
mov eax, dword [ebp+0CH] | |
add dword [ebp-14H], eax | |
L_039: mov eax, dword [ebp-14H] | |
leave | |
ret | |
readFile: | |
push ebp | |
mov ebp, esp | |
sub esp, 1048 | |
mov dword [ebp-0CH], 0 | |
mov dword [ebp-10H], 1024 | |
sub esp, 12 | |
push 1024 | |
call malloc | |
add esp, 16 | |
mov edx, eax | |
mov eax, dword [ebp+0CH] | |
mov dword [eax], edx | |
jmp L_042 | |
L_040: mov edx, dword [ebp-0CH] | |
mov eax, dword [ebp-14H] | |
add eax, edx | |
cmp eax, dword [ebp-10H] | |
jl L_041 | |
shl dword [ebp-10H], 1 | |
mov edx, dword [ebp-10H] | |
mov eax, dword [ebp+0CH] | |
mov eax, dword [eax] | |
sub esp, 8 | |
push edx | |
push eax | |
call realloc | |
add esp, 16 | |
mov edx, eax | |
mov eax, dword [ebp+0CH] | |
mov dword [eax], edx | |
L_041: mov eax, dword [ebp-14H] | |
mov edx, dword [ebp+0CH] | |
mov ecx, dword [edx] | |
mov edx, dword [ebp-0CH] | |
add edx, ecx | |
sub esp, 4 | |
push eax | |
lea eax, [ebp-414H] | |
push eax | |
push edx | |
call memcpy | |
add esp, 16 | |
mov eax, dword [ebp-14H] | |
add dword [ebp-0CH], eax | |
L_042: push dword [ebp+8H] | |
push 1024 | |
push 1 | |
lea eax, [ebp-414H] | |
push eax | |
call fread | |
add esp, 16 | |
mov dword [ebp-14H], eax | |
cmp dword [ebp-14H], 0 | |
jg L_040 | |
mov edx, dword [ebp-0CH] | |
mov eax, dword [ebp+10H] | |
lea ecx, [edx+eax] | |
mov eax, dword [ebp-0CH] | |
cdq | |
idiv dword [ebp+10H] | |
mov eax, edx | |
sub ecx, eax | |
mov eax, ecx | |
cmp eax, dword [ebp-10H] | |
jle L_043 | |
mov edx, dword [ebp-0CH] | |
mov eax, dword [ebp+10H] | |
lea ecx, [edx+eax] | |
mov eax, dword [ebp-0CH] | |
cdq | |
idiv dword [ebp+10H] | |
mov eax, edx | |
sub ecx, eax | |
mov eax, ecx | |
mov edx, eax | |
mov eax, dword [ebp+0CH] | |
mov eax, dword [eax] | |
sub esp, 8 | |
push edx | |
push eax | |
call realloc | |
add esp, 16 | |
mov edx, eax | |
mov eax, dword [ebp+0CH] | |
mov dword [eax], edx | |
L_043: mov eax, dword [ebp+0CH] | |
mov edx, dword [eax] | |
mov eax, dword [ebp-0CH] | |
add eax, edx | |
mov byte [eax], 0 | |
add dword [ebp-0CH], 1 | |
mov eax, dword [ebp-0CH] | |
cdq | |
idiv dword [ebp+10H] | |
mov eax, edx | |
test eax, eax | |
jnz L_043 | |
mov eax, dword [ebp-0CH] | |
leave | |
ret | |
encode: | |
push ebp | |
mov ebp, esp | |
push ebx | |
sub esp, 4 | |
mov eax, dword [ebp+0CH] | |
mov ecx, eax | |
mov ebx, eax | |
sar ebx, 31 | |
mov eax, dword [ebp+8H] | |
cdq | |
sub esp, 12 | |
push dword [ebp+10H] | |
push ebx | |
push ecx | |
push edx | |
push eax | |
call modpow | |
add esp, 32 | |
mov ebx, dword [ebp-4H] | |
leave | |
ret | |
decode: | |
push ebp | |
mov ebp, esp | |
push ebx | |
sub esp, 4 | |
mov eax, dword [ebp+0CH] | |
mov ecx, eax | |
mov ebx, eax | |
sar ebx, 31 | |
mov eax, dword [ebp+8H] | |
cdq | |
sub esp, 12 | |
push dword [ebp+10H] | |
push ebx | |
push ecx | |
push edx | |
push eax | |
call modpow | |
add esp, 32 | |
mov ebx, dword [ebp-4H] | |
leave | |
ret | |
encodeMessage: | |
push ebp | |
mov ebp, esp | |
push ebx | |
sub esp, 20 | |
mov eax, dword [ebp+8H] | |
cdq | |
idiv dword [ebp+0CH] | |
shl eax, 2 | |
sub esp, 12 | |
push eax | |
call malloc | |
add esp, 16 | |
mov dword [ebp-18H], eax | |
mov dword [ebp-10H], 0 | |
jmp L_047 | |
L_044: mov dword [ebp-0CH], 0 | |
mov dword [ebp-14H], 0 | |
jmp L_046 | |
L_045: mov edx, dword [ebp-10H] | |
mov eax, dword [ebp-14H] | |
add eax, edx | |
mov edx, eax | |
mov eax, dword [ebp+10H] | |
add eax, edx | |
movzx eax, byte [eax] | |
movsx ebx, al | |
mov edx, dword [ebp-14H] | |
mov eax, edx | |
shl eax, 3 | |
sub eax, edx | |
mov ecx, eax | |
shl ebx, cl | |
mov eax, ebx | |
add dword [ebp-0CH], eax | |
add dword [ebp-14H], 1 | |
L_046: mov eax, dword [ebp-14H] | |
cmp eax, dword [ebp+0CH] | |
jl L_045 | |
mov eax, dword [ebp-10H] | |
cdq | |
idiv dword [ebp+0CH] | |
lea edx, [eax*4] | |
mov eax, dword [ebp-18H] | |
lea ebx, [edx+eax] | |
sub esp, 4 | |
push dword [ebp+18H] | |
push dword [ebp+14H] | |
push dword [ebp-0CH] | |
call encode | |
add esp, 16 | |
mov dword [ebx], eax | |
mov eax, dword [ebp-10H] | |
cdq | |
idiv dword [ebp+0CH] | |
lea edx, [eax*4] | |
mov eax, dword [ebp-18H] | |
add eax, edx | |
mov eax, dword [eax] | |
sub esp, 8 | |
push eax | |
push L_062 | |
call printf | |
add esp, 16 | |
mov eax, dword [ebp+0CH] | |
add dword [ebp-10H], eax | |
L_047: mov eax, dword [ebp-10H] | |
cmp eax, dword [ebp+8H] | |
jl L_044 | |
mov eax, dword [ebp-18H] | |
mov ebx, dword [ebp-4H] | |
leave | |
ret | |
decodeMessage: | |
push ebp | |
mov ebp, esp | |
push ebx | |
sub esp, 20 | |
mov eax, dword [ebp+8H] | |
imul eax, dword [ebp+0CH] | |
shl eax, 2 | |
sub esp, 12 | |
push eax | |
call malloc | |
add esp, 16 | |
mov dword [ebp-14H], eax | |
mov dword [ebp-0CH], 0 | |
jmp L_052 | |
L_048: mov eax, dword [ebp-0CH] | |
lea edx, [eax*4] | |
mov eax, dword [ebp+10H] | |
add eax, edx | |
mov eax, dword [eax] | |
sub esp, 4 | |
push dword [ebp+18H] | |
push dword [ebp+14H] | |
push eax | |
call decode | |
add esp, 16 | |
mov dword [ebp-18H], eax | |
mov dword [ebp-10H], 0 | |
jmp L_051 | |
L_049: mov eax, dword [ebp-0CH] | |
imul eax, dword [ebp+0CH] | |
mov edx, eax | |
mov eax, dword [ebp-10H] | |
add eax, edx | |
lea edx, [eax*4] | |
mov eax, dword [ebp-14H] | |
lea ebx, [edx+eax] | |
mov edx, dword [ebp-10H] | |
mov eax, edx | |
shl eax, 3 | |
sub eax, edx | |
mov edx, dword [ebp-18H] | |
mov ecx, eax | |
sar edx, cl | |
mov eax, edx | |
sar eax, 31 | |
shr eax, 25 | |
add edx, eax | |
and edx, 7FH | |
sub edx, eax | |
mov eax, edx | |
mov dword [ebx], eax | |
mov eax, dword [ebp-0CH] | |
imul eax, dword [ebp+0CH] | |
mov edx, eax | |
mov eax, dword [ebp-10H] | |
add eax, edx | |
lea edx, [eax*4] | |
mov eax, dword [ebp-14H] | |
add eax, edx | |
mov eax, dword [eax] | |
test eax, eax | |
jz L_050 | |
mov eax, dword [ebp-0CH] | |
imul eax, dword [ebp+0CH] | |
mov edx, eax | |
mov eax, dword [ebp-10H] | |
add eax, edx | |
lea edx, [eax*4] | |
mov eax, dword [ebp-14H] | |
add eax, edx | |
mov eax, dword [eax] | |
sub esp, 12 | |
push eax | |
call putchar | |
add esp, 16 | |
L_050: add dword [ebp-10H], 1 | |
L_051: mov eax, dword [ebp-10H] | |
cmp eax, dword [ebp+0CH] | |
jl L_049 | |
add dword [ebp-0CH], 1 | |
L_052: mov eax, dword [ebp-0CH] | |
cmp eax, dword [ebp+8H] | |
jl L_048 | |
mov eax, dword [ebp-14H] | |
mov ebx, dword [ebp-4H] | |
leave | |
ret | |
main: | |
lea ecx, [esp+4H] | |
and esp, 0FFFFFFF0H | |
push dword [ecx-4H] | |
push ebp | |
mov ebp, esp | |
push ecx | |
sub esp, 52 | |
sub esp, 12 | |
push 0 | |
call time | |
add esp, 16 | |
sub esp, 12 | |
push eax | |
call srand | |
add esp, 16 | |
L_053: sub esp, 12 | |
push 10000 | |
call randPrime | |
add esp, 16 | |
mov dword [ebp-10H], eax | |
sub esp, 8 | |
push dword [ebp-10H] | |
push L_063 | |
call printf | |
add esp, 16 | |
call getchar | |
sub esp, 12 | |
push 10000 | |
call randPrime | |
add esp, 16 | |
mov dword [ebp-14H], eax | |
sub esp, 8 | |
push dword [ebp-14H] | |
push L_064 | |
call printf | |
add esp, 16 | |
call getchar | |
mov eax, dword [ebp-10H] | |
imul eax, dword [ebp-14H] | |
mov dword [ebp-18H], eax | |
sub esp, 8 | |
push dword [ebp-18H] | |
push L_065 | |
call printf | |
add esp, 16 | |
cmp dword [ebp-18H], 127 | |
jg L_054 | |
sub esp, 12 | |
push L_066 | |
call printf | |
add esp, 16 | |
call getchar | |
jmp L_055 | |
L_054: nop | |
mov eax, dword [ebp-18H] | |
sar eax, 21 | |
test eax, eax | |
jz L_057 | |
jmp L_056 | |
L_055: jmp L_053 | |
L_056: mov dword [ebp-0CH], 3 | |
jmp L_059 | |
L_057: mov eax, dword [ebp-18H] | |
sar eax, 14 | |
test eax, eax | |
jz L_058 | |
mov dword [ebp-0CH], 2 | |
jmp L_059 | |
L_058: mov dword [ebp-0CH], 1 | |
L_059: call getchar | |
mov eax, dword [ebp-10H] | |
lea edx, [eax-1H] | |
mov eax, dword [ebp-14H] | |
sub eax, 1 | |
imul eax, edx | |
mov dword [ebp-1CH], eax | |
sub esp, 8 | |
push dword [ebp-1CH] | |
push L_067 | |
call printf | |
add esp, 16 | |
call getchar | |
sub esp, 8 | |
push 1000 | |
push dword [ebp-1CH] | |
call randExponent | |
add esp, 16 | |
mov dword [ebp-20H], eax | |
push dword [ebp-18H] | |
push dword [ebp-20H] | |
push dword [ebp-20H] | |
push L_068 | |
call printf | |
add esp, 16 | |
call getchar | |
sub esp, 8 | |
push dword [ebp-1CH] | |
push dword [ebp-20H] | |
call inverse | |
add esp, 16 | |
mov dword [ebp-24H], eax | |
push dword [ebp-18H] | |
push dword [ebp-24H] | |
push dword [ebp-24H] | |
push L_069 | |
call printf | |
add esp, 16 | |
call getchar | |
sub esp, 12 | |
push L_070 | |
call puts | |
add esp, 16 | |
sub esp, 8 | |
push L_071 | |
push L_072 | |
call fopen | |
add esp, 16 | |
mov dword [ebp-28H], eax | |
cmp dword [ebp-28H], 0 | |
jnz L_060 | |
sub esp, 12 | |
push L_073 | |
call puts | |
add esp, 16 | |
mov eax, 1 | |
jmp L_061 | |
L_060: sub esp, 4 | |
push dword [ebp-0CH] | |
lea eax, [ebp-38H] | |
push eax | |
push dword [ebp-28H] | |
call readFile | |
add esp, 16 | |
mov dword [ebp-2CH], eax | |
sub esp, 12 | |
push dword [ebp-28H] | |
call fclose | |
add esp, 16 | |
sub esp, 4 | |
push dword [ebp-0CH] | |
push dword [ebp-2CH] | |
push L_074 | |
call printf | |
add esp, 16 | |
call getchar | |
mov eax, dword [ebp-38H] | |
sub esp, 12 | |
push dword [ebp-18H] | |
push dword [ebp-20H] | |
push eax | |
push dword [ebp-0CH] | |
push dword [ebp-2CH] | |
call encodeMessage | |
add esp, 32 | |
mov dword [ebp-30H], eax | |
sub esp, 12 | |
push L_075 | |
call printf | |
add esp, 16 | |
call getchar | |
sub esp, 12 | |
push L_076 | |
call printf | |
add esp, 16 | |
call getchar | |
mov eax, dword [ebp-2CH] | |
cdq | |
idiv dword [ebp-0CH] | |
sub esp, 12 | |
push dword [ebp-18H] | |
push dword [ebp-24H] | |
push dword [ebp-30H] | |
push dword [ebp-0CH] | |
push eax | |
call decodeMessage | |
add esp, 32 | |
mov dword [ebp-34H], eax | |
sub esp, 12 | |
push L_077 | |
call puts | |
add esp, 16 | |
sub esp, 12 | |
push dword [ebp-30H] | |
call free | |
add esp, 16 | |
sub esp, 12 | |
push dword [ebp-34H] | |
call free | |
add esp, 16 | |
mov eax, dword [ebp-38H] | |
sub esp, 12 | |
push eax | |
call free | |
add esp, 16 | |
mov eax, 0 | |
L_061: mov ecx, dword [ebp-4H] | |
leave | |
lea esp, [ecx-4H] | |
ret | |
SECTION .rodata align=4 | |
L_062: db "%d ", 00H | |
L_063: db "Got first prime factor, p = %d ... " | |
L_064: db "Got second prime factor, q = %d ... " | |
L_065: | |
db 47H, 6FH, 74H, 20H, 6DH, 6FH, 64H, 75H | |
db 6CH, 75H, 73H, 2CH, 20H, 6EH, 20H, 3DH | |
db 20H, 70H, 71H, 20H, 3DH, 20H, 25H, 64H | |
db 20H, 2EH, 2EH, 2EH, 20H, 00H, 00H | |
L_066: | |
db 4DH, 6FH, 64H, 75H, 6CH, 75H, 73H, 20H | |
db 69H, 73H, 20H, 6CH, 65H, 73H, 73H, 20H | |
db 74H, 68H, 61H, 6EH, 20H, 31H, 32H, 38H | |
db 2CH, 20H, 63H, 61H, 6EH, 6EH, 6FH, 74H | |
db 20H, 65H, 6EH, 63H, 6FH, 64H, 65H, 20H | |
db 73H, 69H, 6EH, 67H, 6CH, 65H, 20H, 62H | |
db 79H, 74H, 65H, 73H, 2EH, 20H, 54H, 72H | |
db 79H, 69H, 6EH, 67H, 20H, 61H, 67H, 61H | |
db 69H, 6EH, 20H, 2EH, 2EH, 2EH, 20H, 00H | |
L_067: | |
db 47H, 6FH, 74H, 20H, 74H, 6FH, 74H, 69H | |
db 65H, 6EH, 74H, 2CH, 20H, 70H, 68H, 69H | |
db 20H, 3DH, 20H, 25H, 64H, 20H, 2EH, 2EH | |
db 2EH, 20H, 00H, 00H | |
L_068: | |
db 43H, 68H, 6FH, 73H, 65H, 20H, 70H, 75H | |
db 62H, 6CH, 69H, 63H, 20H, 65H, 78H, 70H | |
db 6FH, 6EH, 65H, 6EH, 74H, 2CH, 20H, 65H | |
db 20H, 3DH, 20H, 25H, 64H, 0AH, 50H, 75H | |
db 62H, 6CH, 69H, 63H, 20H, 6BH, 65H, 79H | |
db 20H, 69H, 73H, 20H, 28H, 25H, 64H, 2CH | |
db 20H, 25H, 64H, 29H, 20H, 2EH, 2EH, 2EH | |
db 20H, 00H, 00H, 00H | |
L_069: | |
db 43H, 61H, 6CH, 63H, 75H, 6CH, 61H, 74H | |
db 65H, 64H, 20H, 70H, 72H, 69H, 76H, 61H | |
db 74H, 65H, 20H, 65H, 78H, 70H, 6FH, 6EH | |
db 65H, 6EH, 74H, 2CH, 20H, 64H, 20H, 3DH | |
db 20H, 25H, 64H, 0AH, 50H, 72H, 69H, 76H | |
db 61H, 74H, 65H, 20H, 6BH, 65H, 79H, 20H | |
db 69H, 73H, 20H, 28H, 25H, 64H, 2CH, 20H | |
db 25H, 64H, 29H, 20H, 2EH, 2EH, 2EH, 20H | |
db 00H, 00H, 00H, 00H | |
L_070: | |
db 4FH, 70H, 65H, 6EH, 69H, 6EH, 67H, 20H | |
db 66H, 69H, 6CH, 65H, 20H, 22H, 74H, 65H | |
db 78H, 74H, 2EH, 74H, 78H, 74H, 22H, 20H | |
db 66H, 6FH, 72H, 20H, 72H, 65H, 61H, 64H | |
db 69H, 6EH, 67H, 00H | |
L_071: | |
db 72H, 00H | |
L_072: | |
db 74H, 65H, 78H, 74H, 2EH, 74H, 78H, 74H | |
db 00H, 00H | |
L_073: | |
db 46H, 61H, 69H, 6CH, 65H, 64H, 20H, 74H | |
db 6FH, 20H, 6FH, 70H, 65H, 6EH, 20H, 66H | |
db 69H, 6CH, 65H, 20H, 22H, 74H, 65H, 78H | |
db 74H, 2EH, 74H, 78H, 74H, 22H, 2EH, 20H | |
db 44H, 6FH, 65H, 73H, 20H, 69H, 74H, 20H | |
db 65H, 78H, 69H, 73H, 74H, 3FH, 00H, 00H | |
L_074: | |
db 46H, 69H, 6CH, 65H, 20H, 22H, 74H, 65H | |
db 78H, 74H, 2EH, 74H, 78H, 74H, 22H, 20H | |
db 72H, 65H, 61H, 64H, 20H, 73H, 75H, 63H | |
db 63H, 65H, 73H, 73H, 66H, 75H, 6CH, 6CH | |
db 79H, 2CH, 20H, 25H, 64H, 20H, 62H, 79H | |
db 74H, 65H, 73H, 20H, 72H, 65H, 61H, 64H | |
db 2EH, 20H, 45H, 6EH, 63H, 6FH, 64H, 69H | |
db 6EH, 67H, 20H, 62H, 79H, 74H, 65H, 20H | |
db 73H, 74H, 72H, 65H, 61H, 6DH, 20H, 69H | |
db 6EH, 20H, 63H, 68H, 75H, 6EH, 6BH, 73H | |
db 20H, 6FH, 66H, 20H, 25H, 64H, 20H, 62H | |
db 79H, 74H, 65H, 73H, 20H, 2EH, 2EH, 2EH | |
db 20H, 00H, 00H, 00H | |
L_075: | |
db 0AH, 45H, 6EH, 63H, 6FH, 64H, 69H, 6EH | |
db 67H, 20H, 66H, 69H, 6EH, 69H, 73H, 68H | |
db 65H, 64H, 20H, 73H, 75H, 63H, 63H, 65H | |
db 73H, 73H, 66H, 75H, 6CH, 6CH, 79H, 20H | |
db 2EH, 2EH, 2EH, 20H, 00H | |
L_076: | |
db 44H, 65H, 63H, 6FH, 64H, 69H, 6EH, 67H | |
db 20H, 65H, 6EH, 63H, 6FH, 64H, 65H, 64H | |
db 20H, 6DH, 65H, 73H, 73H, 61H, 67H, 65H | |
db 20H, 2EH, 2EH, 2EH, 20H, 00H | |
L_077: | |
db 0AH, 46H, 69H, 6EH, 69H, 73H, 68H, 65H | |
db 64H, 20H, 52H, 53H, 41H, 20H, 64H, 65H | |
db 6DH, 6FH, 6EH, 73H, 74H, 72H, 61H, 74H | |
db 69H, 6FH, 6EH, 21H, 00H | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment