Тема: [FASM] curve25519
Ріп https://code.google.com/p/curve25519-donna/
Генеруємо приватний ключ (256 біт) і робимо так:
(private_key[0] &= 248;
private_key[31] &= 127;
private_key[31] |= 64;)
mov esi, private_key
and byte[esi], 248
mov dl, byte[esi + 31]
and dl, 127
or dl, 64
mov byte[esi + 31], dl
Потім:
stdcall curve25519, public_key_1, private_key_1, basepoint
stdcall curve25519, public_key_2, private_key_2, basepoint
stdcall curve25519, shared_key_1, private_key_1, public_key_2
stdcall curve25519, shared_key_2, private_key_2, public_key_1
basepoint db 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
В підсумку: shared_key_1 == shared_key_2
Розмір шеллкоду 6809 байт.
curve25519.asm
use32
curve25519:
push ebp
mov ebp, esp
and esp, 0FFFFFFF8h
sub esp, 118h
push 20h
push dword[ebp + 0Ch]
lea eax, [esp + 8h]
push eax
mov edi, dword[esp]
mov esi, dword[esp + 4]
mov ecx, dword[esp + 8]
rep movsb
mov al, byte[esp + 2Bh]
lea ecx, [esp + 2Ch]
mov edx, dword[ebp + 10h]
and al, 3Fh
and byte[esp + 0Ch], 0F8h
add esp, 0Ch
or al, 40h
mov byte[esp + 1Fh], al
call @13
lea eax, [esp + 20h]
push eax
lea eax, [esp + 4h]
push eax
lea edx, [esp + 78h]
lea ecx, [esp + 0D0h]
call @34
lea edx, [esp + 70h]
lea ecx, [esp + 20h]
call @37
lea eax, [esp + 20h]
push eax
lea edx, [esp + 0CCh]
lea ecx, [esp + 74h]
call @10
mov ecx, dword[ebp + 8h]
lea edx, [esp + 70h]
call @15
xor eax, eax
leave
ret 0Ch
@02:
push ebx
push esi
push edi
mov ebx, edx
lea esi, [ecx + 8h]
xor edi, edi
sub edx, ecx
@03:
mov eax, dword[edi * 8h + ebx]
add dword[esi - 8h], eax
mov eax, dword[edi * 8h + ebx + 4h]
adc dword[esi - 4h], eax
mov eax, dword[esi + edx]
add dword[esi], eax
mov eax, dword[esi + edx + 4h]
adc dword[esi + 4h], eax
add edi, 2h
lea esi, [esi + 10h]
cmp edi, 0Ah
jb @03
pop edi
pop esi
pop ebx
ret
@04:
push esi
push edi
mov esi, edx
push 0Ah
sub esi, ecx
pop edi
@05:
mov edx, dword[ecx + esi]
sub edx, dword[ecx]
mov eax, dword[ecx + esi + 4h]
sbb eax, dword[ecx + 4h]
mov dword[ecx], edx
lea ecx, [ecx + 8h]
mov dword[ecx - 4h], eax
sub edi, 1h
jne @05
pop edi
pop esi
ret
@06:
push ebp
mov ebp, esp
push ecx
push ebx
mov ebx, edx
mov dword[ebp - 4h], ecx
push esi
push edi
mov edi, dword[ebp + 8h]
mov eax, dword[ebx]
imul dword[edi]
mov dword[ecx], eax
mov dword[ecx + 4h], edx
mov eax, dword[ebx + 8h]
imul dword[edi]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx]
imul dword[edi + 8h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 8h], ecx
mov dword[eax + 0Ch], esi
mov eax, dword[ebx + 8h]
imul dword[edi + 8h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx]
imul dword[edi + 10h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebx + 10h]
adc esi, edx
imul dword[edi]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 10h], ecx
mov dword[eax + 14h], esi
mov eax, dword[ebx]
imul dword[edi + 18h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 8h]
imul dword[edi + 10h]
add ecx, eax
mov eax, dword[ebx + 10h]
adc esi, edx
imul dword[edi + 8h]
add ecx, eax
mov eax, dword[ebx + 18h]
adc esi, edx
imul dword[edi]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 18h], ecx
mov dword[eax + 1Ch], esi
mov eax, dword[ebx + 18h]
imul dword[edi + 8h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 8h]
imul dword[edi + 18h]
add ecx, eax
mov eax, dword[ebx + 10h]
adc esi, edx
imul dword[edi + 10h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebx + 20h]
adc esi, edx
imul dword[edi]
add ecx, eax
mov eax, dword[ebx]
adc esi, edx
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 20h], ecx
mov dword[eax + 24h], esi
mov eax, dword[ebx]
imul dword[edi + 28h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 8h]
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[ebx + 18h]
adc esi, edx
imul dword[edi + 10h]
add ecx, eax
mov eax, dword[ebx + 20h]
adc esi, edx
imul dword[edi + 8h]
add ecx, eax
mov eax, dword[ebx + 28h]
adc esi, edx
imul dword[edi]
add ecx, eax
mov eax, dword[ebx + 10h]
adc esi, edx
imul dword[edi + 18h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 28h], ecx
mov dword[eax + 2Ch], esi
mov eax, dword[ebx + 18h]
imul dword[edi + 18h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 28h]
imul dword[edi + 8h]
add ecx, eax
mov eax, dword[ebx + 8h]
adc esi, edx
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[ebx + 20h]
adc esi, edx
imul dword[edi + 10h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebx]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[ebx + 30h]
adc esi, edx
imul dword[edi]
add ecx, eax
mov eax, dword[ebx + 10h]
adc esi, edx
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 30h], ecx
mov dword[eax + 34h], esi
mov eax, dword[ebx + 18h]
imul dword[edi + 20h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 10h]
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[ebx + 28h]
adc esi, edx
imul dword[edi + 10h]
add ecx, eax
mov eax, dword[ebx + 30h]
adc esi, edx
imul dword[edi + 8h]
add ecx, eax
mov eax, dword[ebx + 20h]
adc esi, edx
imul dword[edi + 18h]
add ecx, eax
adc esi, edx
mov eax, dword[ebx]
imul dword[edi + 38h]
add ecx, eax
mov eax, dword[ebx + 8h]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[ebx + 38h]
adc esi, edx
imul dword[edi]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 38h], ecx
mov dword[eax + 3Ch], esi
mov eax, dword[ebx + 38h]
imul dword[edi + 8h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 8h]
imul dword[edi + 38h]
add ecx, eax
mov eax, dword[ebx + 18h]
adc esi, edx
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[ebx + 28h]
adc esi, edx
imul dword[edi + 18h]
add ecx, eax
mov eax, dword[ebx + 10h]
adc esi, edx
imul dword[edi + 30h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebx + 20h]
adc esi, edx
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[ebx]
adc esi, edx
imul dword[edi + 40h]
add ecx, eax
mov eax, dword[ebx + 30h]
adc esi, edx
imul dword[edi + 10h]
add ecx, eax
mov eax, dword[ebx + 40h]
adc esi, edx
imul dword[edi]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 40h], ecx
mov dword[eax + 44h], esi
mov eax, dword[ebx + 20h]
imul dword[edi + 28h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 40h]
imul dword[edi + 8h]
add ecx, eax
mov eax, dword[ebx]
adc esi, edx
imul dword[edi + 48h]
add ecx, eax
mov eax, dword[ebx + 48h]
adc esi, edx
imul dword[edi]
add ecx, eax
mov eax, dword[ebx + 8h]
adc esi, edx
imul dword[edi + 40h]
add ecx, eax
mov eax, dword[ebx + 30h]
adc esi, edx
imul dword[edi + 18h]
add ecx, eax
mov eax, dword[ebx + 18h]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[ebx + 38h]
adc esi, edx
imul dword[edi + 10h]
add ecx, eax
mov eax, dword[ebx + 10h]
adc esi, edx
imul dword[edi + 38h]
add ecx, eax
mov eax, dword[ebx + 28h]
adc esi, edx
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 48h], ecx
mov dword[eax + 4Ch], esi
mov eax, dword[ebx + 18h]
imul dword[edi + 38h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 38h]
imul dword[edi + 18h]
add ecx, eax
mov eax, dword[ebx + 48h]
adc esi, edx
imul dword[edi + 8h]
add ecx, eax
mov eax, dword[ebx + 28h]
adc esi, edx
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[ebx + 8h]
adc esi, edx
imul dword[edi + 48h]
add ecx, eax
mov eax, dword[ebx + 20h]
adc esi, edx
imul dword[edi + 30h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebx + 30h]
adc esi, edx
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[ebx + 40h]
adc esi, edx
imul dword[edi + 10h]
add ecx, eax
mov eax, dword[ebx + 10h]
adc esi, edx
imul dword[edi + 40h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 50h], ecx
mov dword[eax + 54h], esi
mov eax, dword[ebx + 18h]
imul dword[edi + 40h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 38h]
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[ebx + 40h]
adc esi, edx
imul dword[edi + 18h]
add ecx, eax
mov eax, dword[ebx + 10h]
adc esi, edx
imul dword[edi + 48h]
add ecx, eax
mov eax, dword[ebx + 28h]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[ebx + 20h]
adc esi, edx
imul dword[edi + 38h]
add ecx, eax
mov eax, dword[ebx + 30h]
adc esi, edx
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[ebx + 48h]
adc esi, edx
imul dword[edi + 10h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 58h], ecx
mov dword[eax + 5Ch], esi
mov eax, dword[ebx + 48h]
imul dword[edi + 18h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 38h]
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[ebx + 18h]
adc esi, edx
imul dword[edi + 48h]
add ecx, eax
mov eax, dword[ebx + 28h]
adc esi, edx
imul dword[edi + 38h]
add ecx, eax
mov eax, dword[ebx + 40h]
adc esi, edx
imul dword[edi + 20h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebx + 20h]
adc esi, edx
imul dword[edi + 40h]
add ecx, eax
mov eax, dword[ebx + 30h]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 60h], ecx
mov dword[eax + 64h], esi
mov eax, dword[ebx + 20h]
imul dword[edi + 48h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 30h]
imul dword[edi + 38h]
add ecx, eax
mov eax, dword[ebx + 48h]
adc esi, edx
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[ebx + 38h]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[ebx + 40h]
adc esi, edx
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[ebx + 28h]
adc esi, edx
imul dword[edi + 40h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 68h], ecx
mov dword[eax + 6Ch], esi
mov eax, dword[ebx + 38h]
imul dword[edi + 38h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 28h]
imul dword[edi + 48h]
add ecx, eax
adc esi, edx
mov eax, dword[ebx + 48h]
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[ebx + 30h]
adc esi, edx
imul dword[edi + 40h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebx + 40h]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 70h], ecx
mov dword[eax + 74h], esi
mov eax, dword[ebx + 38h]
imul dword[edi + 40h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 40h]
imul dword[edi + 38h]
add ecx, eax
mov eax, dword[ebx + 30h]
adc esi, edx
imul dword[edi + 48h]
add ecx, eax
mov eax, dword[ebx + 48h]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 78h], ecx
mov dword[eax + 7Ch], esi
mov eax, dword[ebx + 48h]
imul dword[edi + 38h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 38h]
imul dword[edi + 48h]
add ecx, eax
mov eax, dword[ebx + 40h]
adc esi, edx
imul dword[edi + 40h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 80h], ecx
mov dword[eax + 84h], esi
mov eax, dword[ebx + 48h]
imul dword[edi + 40h]
mov ecx, eax
mov esi, edx
mov eax, dword[ebx + 40h]
imul dword[edi + 48h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 88h], ecx
mov ecx, eax
mov dword[ecx + 8Ch], esi
mov eax, dword[ebx + 48h]
imul dword[edi + 48h]
pop edi
shld edx, eax, 1h
pop esi
add eax, eax
mov dword[ecx + 94h], edx
mov dword[ecx + 90h], eax
pop ebx
leave
ret 4h
@07:
push ebx
mov ebx, ecx
push esi
push edi
mov esi, dword[ebx + 90h]
mov eax, esi
mov edi, dword[ebx + 94h]
mov edx, edi
shld edx, eax, 4h
mov ecx, edi
shl eax, 4h
add dword[ebx + 40h], eax
mov eax, esi
adc dword[ebx + 44h], edx
shld ecx, eax, 1h
mov edx, dword[ebx + 88h]
add eax, eax
add dword[ebx + 40h], eax
mov eax, edx
adc dword[ebx + 44h], ecx
add dword[ebx + 40h], esi
mov esi, dword[ebx + 8Ch]
mov ecx, esi
adc dword[ebx + 44h], edi
shld ecx, eax, 4h
shl eax, 4h
add dword[ebx + 38h], eax
mov eax, edx
adc dword[ebx + 3Ch], ecx
mov ecx, esi
shld ecx, eax, 1h
add eax, eax
add dword[ebx + 38h], eax
adc dword[ebx + 3Ch], ecx
add dword[ebx + 38h], edx
mov edx, dword[ebx + 80h]
mov eax, edx
adc dword[ebx + 3Ch], esi
mov esi, dword[ebx + 84h]
mov ecx, esi
shld ecx, eax, 4h
shl eax, 4h
add dword[ebx + 30h], eax
mov eax, edx
adc dword[ebx + 34h], ecx
mov ecx, esi
shld ecx, eax, 1h
add eax, eax
add dword[ebx + 30h], eax
adc dword[ebx + 34h], ecx
add dword[ebx + 30h], edx
mov edx, dword[ebx + 78h]
mov eax, edx
adc dword[ebx + 34h], esi
mov esi, dword[ebx + 7Ch]
mov ecx, esi
shld ecx, eax, 4h
shl eax, 4h
add dword[ebx + 28h], eax
mov eax, edx
adc dword[ebx + 2Ch], ecx
mov ecx, esi
shld ecx, eax, 1h
add eax, eax
add dword[ebx + 28h], eax
adc dword[ebx + 2Ch], ecx
add dword[ebx + 28h], edx
mov edx, dword[ebx + 70h]
mov eax, edx
adc dword[ebx + 2Ch], esi
mov esi, dword[ebx + 74h]
mov ecx, esi
shld ecx, eax, 4h
shl eax, 4h
add dword[ebx + 20h], eax
mov eax, edx
adc dword[ebx + 24h], ecx
mov ecx, esi
shld ecx, eax, 1h
add eax, eax
add dword[ebx + 20h], eax
adc dword[ebx + 24h], ecx
add dword[ebx + 20h], edx
mov edx, dword[ebx + 68h]
mov eax, edx
adc dword[ebx + 24h], esi
mov esi, dword[ebx + 6Ch]
mov ecx, esi
shld ecx, eax, 4h
pop edi
shl eax, 4h
add dword[ebx + 18h], eax
mov eax, edx
adc dword[ebx + 1Ch], ecx
mov ecx, esi
shld ecx, eax, 1h
add eax, eax
add dword[ebx + 18h], eax
adc dword[ebx + 1Ch], ecx
add dword[ebx + 18h], edx
mov edx, dword[ebx + 60h]
mov eax, edx
adc dword[ebx + 1Ch], esi
mov esi, dword[ebx + 64h]
mov ecx, esi
shld ecx, eax, 4h
shl eax, 4h
add dword[ebx + 10h], eax
mov eax, edx
adc dword[ebx + 14h], ecx
mov ecx, esi
shld ecx, eax, 1h
add eax, eax
add dword[ebx + 10h], eax
adc dword[ebx + 14h], ecx
add dword[ebx + 10h], edx
mov edx, dword[ebx + 58h]
mov eax, edx
adc dword[ebx + 14h], esi
mov esi, dword[ebx + 5Ch]
mov ecx, esi
shld ecx, eax, 4h
shl eax, 4h
add dword[ebx + 8h], eax
mov eax, edx
adc dword[ebx + 0Ch], ecx
mov ecx, esi
shld ecx, eax, 1h
add eax, eax
add dword[ebx + 8h], eax
adc dword[ebx + 0Ch], ecx
add dword[ebx + 8h], edx
mov edx, dword[ebx + 50h]
mov eax, edx
adc dword[ebx + 0Ch], esi
mov esi, dword[ebx + 54h]
mov ecx, esi
shld ecx, eax, 4h
shl eax, 4h
add dword[ebx], eax
mov eax, edx
adc dword[ebx + 4h], ecx
mov ecx, esi
shld ecx, eax, 1h
add eax, eax
add dword[ebx], eax
adc dword[ebx + 4h], ecx
add dword[ebx], edx
adc dword[ebx + 4h], esi
pop esi
pop ebx
ret
@08:
push ebp
mov ebp, esp
sub esp, 0Ch
and dword[ecx + 50h], 00000000h
lea eax, [ecx + 8h]
and dword[ecx + 54h], 00000000h
push ebx
push esi
push edi
mov dword[ebp - 0Ch], ecx
mov dword[ebp - 4h], eax
mov dword[ebp - 8h], 5h
@09:
mov ebx, dword[eax - 8h]
mov edi, dword[eax - 4h]
mov eax, edi
sar eax, 1Fh
shr eax, 6h
cdq
mov esi, eax
add esi, ebx
adc edx, edi
shrd esi, edx, 1Ah
sar edx, 1Ah
mov eax, esi
mov ecx, edx
shld ecx, eax, 1Ah
shl eax, 1Ah
sub ebx, eax
mov eax, dword[ebp - 4h]
sbb edi, ecx
add dword[eax], esi
mov dword[eax - 8h], ebx
adc dword[eax + 4h], edx
mov ebx, dword[eax]
mov dword[eax - 4h], edi
mov edi, dword[eax + 4h]
mov eax, edi
sar eax, 1Fh
shr eax, 7h
cdq
mov esi, eax
add esi, ebx
adc edx, edi
shrd esi, edx, 19h
sar edx, 19h
mov eax, esi
mov ecx, edx
shld ecx, eax, 19h
shl eax, 19h
sub ebx, eax
mov eax, dword[ebp - 4h]
sbb edi, ecx
add dword[eax + 8h], esi
mov dword[eax], ebx
adc dword[eax + 0Ch], edx
mov dword[eax + 4h], edi
add eax, 10h
sub dword[ebp - 8h], 1h
mov dword[ebp - 4h], eax
jne @09
mov edi, dword[ebp - 0Ch]
mov edx, dword[edi + 50h]
mov eax, edx
mov esi, dword[edi + 54h]
mov ecx, esi
shld ecx, eax, 4h
shl eax, 4h
add dword[edi], eax
mov eax, edx
adc dword[edi + 4h], ecx
mov ecx, esi
shld ecx, eax, 1h
add eax, eax
add dword[edi], eax
adc dword[edi + 4h], ecx
add dword[edi], edx
mov ebx, dword[edi]
adc dword[edi + 4h], esi
and dword[edi + 50h], 00000000h
and dword[edi + 54h], 00000000h
mov edi, dword[edi + 4h]
mov eax, edi
sar eax, 1Fh
shr eax, 6h
cdq
mov esi, eax
add esi, ebx
adc edx, edi
shrd esi, edx, 1Ah
sar edx, 1Ah
mov eax, esi
mov ecx, edx
shld ecx, eax, 1Ah
shl eax, 1Ah
sub ebx, eax
sbb edi, ecx
mov ecx, dword[ebp - 0Ch]
add dword[ecx + 8h], esi
mov dword[ecx + 4h], edi
adc dword[ecx + 0Ch], edx
pop edi
pop esi
mov dword[ecx], ebx
pop ebx
leave
ret
@10:
push ebp
mov ebp, esp
sub esp, 9Ch
push esi
push edi
push dword[ebp + 8h]
mov edi, ecx
lea ecx, [ebp - 9Ch]
call @06
lea ecx, [ebp - 9Ch]
call @07
lea ecx, [ebp - 9Ch]
call @08
push 14h
pop ecx
lea esi, [ebp - 9Ch]
rep movsd
pop edi
pop esi
leave
ret 4h
@11:
push ebp
mov ebp, esp
sub esp, 20h
push ebx
push esi
push edi
mov edi, edx
mov dword[ebp - 4h], ecx
mov eax, dword[edi]
imul eax
mov ebx, dword[edi + 8h]
mov dword[ecx], eax
mov eax, dword[edi]
mov dword[ecx + 4h], edx
imul ebx
shld edx, eax, 1h
add eax, eax
mov dword[ecx + 0Ch], edx
mov dword[ecx + 8h], eax
mov ecx, dword[edi + 10h]
mov eax, dword[edi]
imul ecx
mov dword[ebp - 20h], ecx
mov ecx, eax
mov esi, edx
mov eax, ebx
imul ebx
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
mov dword[eax + 14h], esi
add ecx, ecx
mov dword[eax + 10h], ecx
mov ecx, dword[edi + 18h]
mov eax, dword[edi]
imul ecx
mov dword[ebp - 18h], ecx
mov ecx, eax
mov esi, edx
mov eax, ebx
imul dword[edi + 10h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
mov dword[eax + 1Ch], esi
add ecx, ecx
mov dword[eax + 18h], ecx
mov eax, dword[edi + 20h]
mov dword[ebp - 14h], eax
mov eax, ebx
imul dword[edi + 18h]
mov ecx, eax
mov esi, edx
mov eax, dword[edi]
imul dword[edi + 20h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[edi + 10h]
adc esi, edx
imul eax
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 20h], ecx
mov ecx, dword[edi + 28h]
mov dword[eax + 24h], esi
mov eax, dword[edi]
imul ecx
mov dword[ebp - 10h], ecx
mov ecx, eax
mov esi, edx
mov eax, ebx
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[edi + 10h]
adc esi, edx
imul dword[edi + 18h]
add ecx, eax
adc esi, edx
shld esi, ecx, 1h
mov eax, dword[ebp - 4h]
add ecx, ecx
mov dword[eax + 28h], ecx
mov dword[eax + 2Ch], esi
mov eax, dword[edi + 30h]
mov dword[ebp - 8h], eax
mov eax, ebx
imul dword[edi + 28h]
mov ecx, eax
mov esi, edx
mov eax, dword[edi]
imul dword[edi + 30h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[edi + 10h]
adc esi, edx
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[edi + 18h]
adc esi, edx
imul eax
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
mov dword[eax + 34h], esi
add ecx, ecx
mov dword[eax + 30h], ecx
mov ecx, dword[edi + 38h]
mov eax, dword[edi]
imul ecx
mov dword[ebp - 0Ch], ecx
mov ecx, eax
mov esi, edx
mov eax, ebx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[edi + 10h]
adc esi, edx
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[edi + 18h]
adc esi, edx
imul dword[edi + 20h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
mov dword[eax + 3Ch], esi
add ecx, ecx
mov dword[eax + 38h], ecx
mov eax, ebx
imul dword[edi + 38h]
mov ebx, dword[edi + 48h]
mov ecx, eax
mov esi, edx
mov eax, dword[edi + 18h]
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[edi]
adc esi, edx
imul dword[edi + 40h]
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[edi + 10h]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[edi + 20h]
adc esi, edx
imul eax
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 40h], ecx
mov dword[eax + 44h], esi
mov eax, dword[edi]
imul ebx
mov ecx, eax
mov esi, edx
mov eax, dword[edi + 8h]
imul dword[edi + 40h]
add ecx, eax
mov eax, dword[edi + 10h]
adc esi, edx
imul dword[edi + 38h]
add ecx, eax
mov eax, dword[edi + 18h]
adc esi, edx
imul dword[edi + 30h]
add ecx, eax
mov eax, dword[edi + 20h]
adc esi, edx
imul dword[edi + 28h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
mov dword[eax + 4Ch], esi
add ecx, ecx
mov dword[eax + 48h], ecx
mov eax, dword[edi + 8h]
imul ebx
mov ecx, eax
mov esi, edx
mov eax, dword[edi + 18h]
imul dword[edi + 38h]
add ecx, eax
mov eax, dword[edi + 10h]
mov edi, dword[edi + 40h]
adc esi, edx
imul edi
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebp - 14h]
adc esi, edx
imul dword[ebp - 8h]
add ecx, eax
mov eax, dword[ebp - 10h]
adc esi, edx
imul eax
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
mov dword[eax + 54h], esi
add ecx, ecx
mov dword[eax + 50h], ecx
mov eax, dword[ebp - 20h]
imul ebx
mov ecx, eax
mov esi, edx
mov eax, dword[ebp - 18h]
imul edi
add ecx, eax
mov eax, dword[ebp - 14h]
adc esi, edx
imul dword[ebp - 0Ch]
add ecx, eax
mov eax, dword[ebp - 10h]
adc esi, edx
imul dword[ebp - 8h]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
add ecx, ecx
mov dword[eax + 5Ch], esi
mov dword[eax + 58h], ecx
mov eax, dword[ebp - 18h]
imul ebx
mov ecx, eax
mov esi, edx
mov eax, dword[ebp - 10h]
imul dword[ebp - 0Ch]
add ecx, eax
adc esi, edx
mov eax, dword[ebp - 14h]
imul edi
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebp - 8h]
adc esi, edx
imul eax
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 60h], ecx
mov dword[eax + 64h], esi
mov eax, dword[ebp - 14h]
imul ebx
mov ecx, eax
mov esi, edx
mov eax, dword[ebp - 10h]
imul edi
add ecx, eax
mov eax, dword[ebp - 8h]
adc esi, edx
imul dword[ebp - 0Ch]
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
mov dword[eax + 6Ch], esi
add ecx, ecx
mov dword[eax + 68h], ecx
mov eax, dword[ebp - 10h]
imul ebx
mov ecx, eax
mov esi, edx
mov eax, dword[ebp - 8h]
imul edi
shld esi, ecx, 1h
add ecx, ecx
add ecx, eax
mov eax, dword[ebp - 0Ch]
adc esi, edx
imul eax
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
mov dword[eax + 74h], esi
add ecx, ecx
mov dword[eax + 70h], ecx
mov eax, dword[ebp - 8h]
imul ebx
mov ecx, eax
mov esi, edx
mov eax, dword[ebp - 0Ch]
imul edi
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
shld esi, ecx, 1h
mov dword[eax + 7Ch], esi
add ecx, ecx
mov dword[eax + 78h], ecx
mov eax, dword[ebp - 0Ch]
imul ebx
mov ecx, eax
mov esi, edx
shld esi, ecx, 2h
mov eax, edi
imul edi
shl ecx, 2h
add ecx, eax
mov eax, dword[ebp - 4h]
adc esi, edx
mov dword[eax + 80h], ecx
mov ecx, eax
mov eax, edi
imul ebx
mov dword[ecx + 84h], esi
shld edx, eax, 1h
pop edi
add eax, eax
mov dword[ecx + 8Ch], edx
mov dword[ecx + 88h], eax
mov eax, ebx
imul ebx
pop esi
shld edx, eax, 1h
pop ebx
add eax, eax
mov dword[ecx + 94h], edx
mov dword[ecx + 90h], eax
leave
ret
@12:
push ebp
mov ebp, esp
sub esp, 98h
push esi
push edi
mov edi, ecx
lea ecx, [ebp - 98h]
call @11
lea ecx, [ebp - 98h]
call @07
lea ecx, [ebp - 98h]
call @08
push 14h
pop ecx
lea esi, [ebp - 98h]
rep movsd
pop edi
pop esi
leave
ret
@13:
push ebp
mov ebp, esp
sub esp, 0Ch
mov dword[ebp - 0Ch], ecx
mov ecx, edx
mov dword[ebp - 8h], edx
push ebx
push esi
mov bl, byte[ecx + 3h]
push edi
movzx eax, bl
cdq
mov edi, eax
shr bl, 2h
movzx eax, byte[ecx + 2h]
mov esi, edx
cdq
shld esi, edi, 8h
or esi, edx
shl edi, 8h
or edi, eax
movzx eax, byte[ecx]
cdq
shld esi, edi, 10h
xor esi, esi
shl edi, 10h
or edi, eax
movzx eax, byte[ecx + 1h]
cdq
xor ecx, ecx
and eax, 0003FFFFh
and edi, 03FFFFFFh
shld ecx, eax, 8h
shl eax, 8h
or esi, ecx
mov ecx, dword[ebp - 8h]
or edi, eax
mov eax, dword[ebp - 0Ch]
mov dword[eax + 4h], esi
mov dword[eax], edi
mov al, byte[ecx + 6h]
mov byte[ebp - 1h], al
and al, 07h
movzx eax, al
cdq
mov esi, eax
mov edi, edx
movzx eax, byte[ecx + 5h]
shld edi, esi, 8h
cdq
and eax, 000007FFh
shl esi, 8h
or esi, eax
movzx eax, byte[ecx + 4h]
cdq
mov ecx, eax
movzx eax, bl
shld edx, ecx, 6h
shld edi, esi, 0Eh
cdq
shl ecx, 6h
or ecx, eax
shl esi, 0Eh
mov eax, dword[ebp - 0Ch]
and ecx, 01FFFFFFh
or esi, ecx
mov ecx, dword[ebp - 8h]
mov dword[eax + 8h], esi
mov bh, byte[ecx + 9h]
mov dword[eax + 0Ch], edi
mov al, bh
and al, 1Fh
movzx eax, al
cdq
mov esi, eax
mov edi, edx
movzx eax, byte[ecx + 8h]
shld edi, esi, 8h
cdq
shl esi, 8h
and eax, 00001FFFh
or esi, eax
shld edi, esi, 0Dh
shl esi, 0Dh
movzx eax, byte[ecx + 7h]
cdq
mov ecx, eax
shr bh, 5h
mov al, byte[ebp - 1h]
shld edx, ecx, 5h
shr al, 3h
movzx eax, al
cdq
shl ecx, 5h
or ecx, eax
mov eax, dword[ebp - 0Ch]
and ecx, 03FFFFFFh
or esi, ecx
mov ecx, dword[ebp - 8h]
mov dword[eax + 10h], esi
mov dword[eax + 14h], edi
mov bl, byte[ecx + 0Ch]
mov al, bl
shr bl, 6h
and al, 3Fh
movzx eax, al
cdq
mov esi, eax
mov edi, edx
movzx eax, byte[ecx + 0Bh]
shld edi, esi, 8h
cdq
and eax, 00003FFFh
shl esi, 8h
or esi, eax
movzx eax, byte[ecx + 0Ah]
cdq
mov ecx, eax
movzx eax, bh
shld edx, ecx, 3h
shld edi, esi, 0Bh
cdq
shl ecx, 3h
or ecx, eax
shl esi, 0Bh
mov eax, dword[ebp - 0Ch]
and ecx, 01FFFFFFh
or esi, ecx
mov ecx, dword[ebp - 8h]
mov dword[eax + 18h], esi
mov dword[eax + 1Ch], edi
movzx eax, byte[ecx + 0Fh]
cdq
mov esi, eax
mov edi, edx
movzx eax, byte[ecx + 0Eh]
cdq
movzx ecx, ax
mov eax, dword[ebp - 8h]
shld edi, esi, 8h
shl esi, 8h
movzx eax, byte[eax + 0Dh]
or esi, ecx
cdq
mov ecx, eax
movzx eax, bl
shld edx, ecx, 2h
shld edi, esi, 0Ah
shl ecx, 2h
cdq
or ecx, eax
shl esi, 0Ah
mov eax, dword[ebp - 0Ch]
and ecx, 03FFFFFFh
or esi, ecx
mov dword[eax + 20h], esi
mov esi, dword[ebp - 8h]
mov dword[eax + 24h], edi
mov bl, byte[esi + 13h]
movzx eax, bl
cdq
mov edi, eax
mov ecx, edx
shld ecx, edi, 8h
shl edi, 8h
movzx eax, byte[esi + 12h]
cdq
or edi, eax
shr bl, 1h
movzx eax, byte[esi + 10h]
or ecx, edx
cdq
xor esi, esi
shld ecx, edi, 10h
xor ecx, ecx
shl edi, 10h
or edi, eax
mov eax, dword[ebp - 8h]
and edi, 01FFFFFFh
movzx eax, byte[eax + 11h]
cdq
and eax, 0001FFFFh
shld ecx, eax, 8h
shl eax, 8h
or esi, ecx
mov ecx, dword[ebp - 8h]
or edi, eax
mov eax, dword[ebp - 0Ch]
mov bh, byte[ecx + 16h]
mov dword[eax + 2Ch], esi
mov dword[eax + 28h], edi
mov al, bh
and al, 07h
shr bh, 3h
movzx eax, al
cdq
mov esi, eax
mov edi, edx
movzx eax, byte[ecx + 15h]
cdq
and eax, 000007FFh
shld edi, esi, 8h
shl esi, 8h
or esi, eax
movzx eax, byte[ecx + 14h]
cdq
mov ecx, eax
movzx eax, bl
shld edx, ecx, 7h
cdq
shld edi, esi, 0Fh
shl ecx, 7h
or ecx, eax
shl esi, 0Fh
mov eax, dword[ebp - 0Ch]
and ecx, 03FFFFFFh
or esi, ecx
mov ecx, dword[ebp - 8h]
mov dword[eax + 30h], esi
mov dword[eax + 34h], edi
mov al, byte[ecx + 19h]
mov byte[ebp - 1h], al
and al, 0Fh
movzx eax, al
cdq
mov esi, eax
mov edi, edx
movzx eax, byte[ecx + 18h]
shld edi, esi, 8h
cdq
and eax, 00000FFFh
shl esi, 8h
or esi, eax
movzx eax, byte[ecx + 17h]
cdq
mov ecx, eax
movzx eax, bh
shld edx, ecx, 5h
cdq
shl ecx, 5h
shld edi, esi, 0Dh
or ecx, eax
mov eax, dword[ebp - 0Ch]
shl esi, 0Dh
and ecx, 01FFFFFFh
or esi, ecx
mov ecx, dword[ebp - 8h]
mov dword[eax + 38h], esi
mov dword[eax + 3Ch], edi
mov bl, byte[ecx + 1Ch]
mov al, bl
shr bl, 6h
and al, 3Fh
movzx eax, al
cdq
mov esi, eax
mov edi, edx
movzx eax, byte[ecx + 1Bh]
cdq
and eax, 00003FFFh
shld edi, esi, 8h
shl esi, 8h
or esi, eax
movzx eax, byte[ecx + 1Ah]
cdq
mov ecx, eax
mov al, byte[ebp - 1h]
shr al, 4h
shld edx, ecx, 4h
movzx eax, al
cdq
shld edi, esi, 0Ch
shl ecx, 4h
or ecx, eax
shl esi, 0Ch
mov eax, dword[ebp - 0Ch]
and ecx, 03FFFFFFh
or esi, ecx
mov ecx, dword[ebp - 8h]
mov dword[eax + 40h], esi
mov dword[eax + 44h], edi
mov al, byte[ecx + 1Fh]
and al, 7Fh
movzx eax, al
cdq
mov esi, eax
mov edi, edx
movzx eax, byte[ecx + 1Eh]
shld edi, esi, 8h
cdq
and eax, 00007FFFh
shl esi, 8h
or esi, eax
movzx eax, byte[ecx + 1Dh]
cdq
mov ecx, eax
movzx eax, bl
shld edx, ecx, 2h
shld edi, esi, 0Ah
shl ecx, 2h
cdq
or ecx, eax
shl esi, 0Ah
mov eax, dword[ebp - 0Ch]
and ecx, 01FFFFFFh
or esi, ecx
mov dword[eax + 4Ch], edi
pop edi
mov dword[eax + 48h], esi
pop esi
pop ebx
leave
ret
@14:
xor ecx, edx
not ecx
mov eax, ecx
shl eax, 10h
and ecx, eax
mov eax, ecx
shl eax, 8h
and ecx, eax
mov eax, ecx
shl eax, 4h
and ecx, eax
mov eax, ecx
shl eax, 2h
and ecx, eax
lea eax, [ecx + ecx]
sar ecx, 1Fh
sar eax, 1Fh
and eax, ecx
ret
@15:
push ebp
mov ebp, esp
sub esp, 44h
push ebx
push esi
push edi
mov dword[ebp - 0Ch], ecx
xor esi, esi
@16:
mov eax, dword[esi * 8h + edx]
mov dword[esi * 4h + ebp - 44h], eax
inc esi
cmp esi, 0Ah
jl @16
push 2h
pop esi
mov edi, esi
@17:
xor ebx, ebx
@18:
mov ecx, dword[ebx * 4h + ebp - 44h]
mov edx, ecx
sar edx, 1Fh
mov eax, ecx
test bl, 01h
je @19
sar eax, 19h
and edx, eax
neg edx
mov eax, edx
shl eax, 19h
jmp @20
@19:
sar eax, 1Ah
and edx, eax
neg edx
mov eax, edx
shl eax, 1Ah
@20:
sub dword[ebx * 4h + ebp - 40h], edx
add eax, ecx
mov dword[ebx * 4h + ebp - 44h], eax
inc ebx
cmp ebx, 9h
jl @18
mov ecx, dword[ebp - 20h]
mov edx, ecx
sar edx, 1Fh
mov eax, ecx
sar eax, 19h
and edx, eax
neg edx
mov eax, edx
shl eax, 19h
add ecx, eax
imul eax, edx, - 13h
mov edx, dword[ebp - 44h]
mov dword[ebp - 20h], ecx
add edx, eax
mov dword[ebp - 44h], edx
sub edi, 1h
jne @17
mov ecx, edx
mov eax, edx
sar eax, 1Ah
mov ebx, 1FFFFFFh
sar ecx, 1Fh
and ecx, eax
neg ecx
mov eax, ecx
shl eax, 1Ah
add edx, eax
sub dword[ebp - 40h], ecx
mov dword[ebp - 44h], edx
@21:
xor edx, edx
@22:
mov eax, dword[edx * 4h + ebp - 44h]
mov ecx, eax
test dl, 01h
je @23
sar ecx, 19h
and eax, ebx
jmp @24
@23:
sar ecx, 1Ah
and eax, 03FFFFFFh
@24:
add dword[edx * 4h + ebp - 40h], ecx
mov dword[edx * 4h + ebp - 44h], eax
inc edx
cmp edx, 9h
jl @22
mov eax, dword[ebp - 20h]
mov ecx, eax
mov edi, dword[ebp - 44h]
and eax, ebx
sar ecx, 19h
mov dword[ebp - 20h], eax
imul eax, ecx, 13h
add edi, eax
mov dword[ebp - 44h], edi
sub esi, 1h
jne @21
lea esi, [edi + 0FC000013h]
xor ebx, ebx
sar esi, 1Fh
inc ebx
not esi
mov dword[ebp - 8h], ebx
mov dword[ebp - 4h], ebx
@25:
mov ecx, dword[ebx * 4h + ebp - 44h]
mov edx, 1FFFFFFh
test bl, 01h
jne @26
mov edx, 3FFFFFFh
@26:
call @14
and esi, eax
inc ebx
cmp ebx, 0Ah
jl @25
mov ebx, dword[ebp - 8h]
mov eax, esi
and eax, 03FFFFEDh
sub edi, eax
mov dword[ebp - 44h], edi
@27:
mov eax, esi
test bl, 01h
je @28
and eax, 01FFFFFFh
jmp @29
@28:
and eax, 03FFFFFFh
@29:
sub dword[ebx * 4h + ebp - 44h], eax
inc ebx
cmp ebx, 0Ah
jl @27
mov eax, dword[ebp - 38h]
shl eax, 5h
mov dword[ebp - 8h], eax
mov eax, dword[ebp - 34h]
shl eax, 6h
mov dword[ebp - 4h], eax
mov eax, dword[ebp - 2Ch]
mov esi, dword[ebp - 0Ch]
add eax, eax
mov dword[ebp - 10h], eax
mov eax, dword[ebp - 28h]
shl eax, 3h
mov dword[ebp - 14h], eax
mov eax, dword[ebp - 24h]
mov ecx, dword[ebp - 44h]
shl eax, 4h
mov dword[ebp - 18h], eax
mov eax, dword[ebp - 20h]
shl eax, 6h
mov edx, dword[ebp - 40h]
mov dword[ebp - 1Ch], eax
mov eax, ecx
sar eax, 8h
mov byte[esi + 1h], al
mov eax, ecx
mov ebx, dword[ebp - 3Ch]
sar eax, 10h
mov byte[esi + 2h], al
shl edx, 2h
mov eax, edx
shl ebx, 3h
sar eax, 8h
mov byte[esi + 4h], al
mov eax, edx
sar eax, 10h
mov byte[esi + 5h], al
mov eax, ebx
sar eax, 8h
mov byte[esi + 7h], al
mov eax, ebx
sar eax, 10h
mov byte[esi], cl
mov byte[esi + 8h], al
sar ecx, 18h
or cl, dl
sar edx, 18h
mov byte[esi + 3h], cl
or dl, bl
mov ecx, dword[ebp - 8h]
mov eax, ecx
sar eax, 8h
mov byte[esi + 0Ah], al
mov eax, ecx
sar eax, 10h
mov byte[esi + 0Bh], al
mov byte[esi + 6h], dl
mov edx, dword[ebp - 4h]
mov eax, edx
sar eax, 8h
mov byte[esi + 0Dh], al
mov eax, edx
sar ebx, 18h
or bl, cl
sar eax, 10h
sar ecx, 18h
or cl, dl
mov byte[esi + 0Eh], al
mov byte[esi + 0Ch], cl
mov ecx, dword[ebp - 30h]
mov eax, ecx
sar eax, 8h
mov byte[esi + 11h], al
mov eax, ecx
sar edx, 18h
sar eax, 10h
mov byte[esi + 0Fh], dl
mov edx, dword[ebp - 10h]
mov byte[esi + 10h], cl
mov byte[esi + 9h], bl
mov byte[esi + 12h], al
sar ecx, 18h
mov eax, edx
or cl, dl
sar eax, 8h
mov byte[esi + 14h], al
mov eax, edx
sar eax, 10h
mov byte[esi + 15h], al
mov byte[esi + 13h], cl
mov ecx, dword[ebp - 14h]
mov eax, ecx
sar eax, 8h
mov byte[esi + 17h], al
mov eax, ecx
sar eax, 10h
sar edx, 18h
or dl, cl
mov byte[esi + 18h], al
mov byte[esi + 16h], dl
mov edx, dword[ebp - 18h]
mov eax, edx
sar eax, 8h
mov byte[esi + 1Ah], al
mov eax, edx
sar ecx, 18h
or cl, dl
sar eax, 10h
mov byte[esi + 1Bh], al
mov byte[esi + 19h], cl
mov ecx, dword[ebp - 1Ch]
mov eax, ecx
sar eax, 8h
mov byte[esi + 1Dh], al
mov eax, ecx
sar edx, 18h
or dl, cl
sar eax, 10h
sar ecx, 18h
pop edi
mov byte[esi + 1Ch], dl
mov byte[esi + 1Eh], al
mov byte[esi + 1Fh], cl
pop esi
pop ebx
leave
ret
@30:
push ebp
mov ebp, esp
sub esp, 1D8h
push ebx
mov ebx, dword[ebp + 14h]
push esi
mov esi, dword[ebp + 10h]
push edi
mov dword[ebp - 8h], ecx
lea edi, [ebp - 18Ch]
push 14h
pop ecx
mov dword[ebp - 0Ch], edx
mov edx, ebx
rep movsd
mov ecx, dword[ebp + 10h]
call @02
lea edx, [ebp - 18Ch]
mov ecx, ebx
call @04
mov esi, dword[ebp + 18h]
lea edi, [ebp - 18Ch]
mov edx, dword[ebp + 1Ch]
push 14h
pop ecx
rep movsd
mov ecx, dword[ebp + 18h]
call @02
mov ecx, dword[ebp + 1Ch]
lea edx, [ebp - 18Ch]
call @04
mov edx, dword[ebp + 18h]
lea ecx, [ebp - 13Ch]
push ebx
call @06
push dword[ebp + 1Ch]
mov edx, dword[ebp + 10h]
lea ecx, [ebp - 0A4h]
call @06
lea ecx, [ebp - 13Ch]
call @07
lea ecx, [ebp - 13Ch]
call @08
lea ecx, [ebp - 0A4h]
call @07
lea ecx, [ebp - 0A4h]
call @08
push 14h
pop ecx
lea esi, [ebp - 13Ch]
lea edi, [ebp - 18Ch]
rep movsd
lea edx, [ebp - 0A4h]
lea ecx, [ebp - 13Ch]
call @02
lea edx, [ebp - 18Ch]
lea ecx, [ebp - 0A4h]
call @04
lea edx, [ebp - 13Ch]
lea ecx, [ebp - 1D4h]
call @12
lea edx, [ebp - 0A4h]
lea ecx, [ebp - 13Ch]
call @12
push dword[ebp + 20h]
lea edx, [ebp - 13Ch]
lea ecx, [ebp - 0A4h]
call @06
lea ecx, [ebp - 0A4h]
call @07
lea ecx, [ebp - 0A4h]
call @08
mov edi, dword[ebp + 8h]
lea esi, [ebp - 1D4h]
mov edx, dword[ebp + 10h]
push 14h
pop ecx
rep movsd
mov edi, dword[ebp + 0Ch]
lea esi, [ebp - 0A4h]
push 14h
pop ecx
rep movsd
lea ecx, [ebp - 1D4h]
call @12
mov edx, ebx
lea ecx, [ebp - 0A4h]
call @12
mov ebx, dword[ebp - 8h]
lea eax, [ebp - 0A4h]
push eax
lea edx, [ebp - 1D4h]
mov ecx, ebx
call @06
mov ecx, ebx
call @07
mov ecx, ebx
call @08
lea edx, [ebp - 1D4h]
lea ecx, [ebp - 0A4h]
call @04
push 48h
lea eax, [ebp - 0ECh]
push 0h
push eax
call @45
add esp, 0Ch
xor esi, esi
@31:
push 0h
push 1DB41h
push dword[esi + ebp - 0A0h]
push dword[esi + ebp - 0A4h]
call @46
mov dword[esi + ebp - 13Ch], eax
mov dword[esi + ebp - 138h], edx
add esi, 8h
cmp esi, 50h
jb @31
lea ecx, [ebp - 13Ch]
call @08
lea edx, [ebp - 1D4h]
lea ecx, [ebp - 13Ch]
call @02
mov ebx, dword[ebp - 0Ch]
lea edx, [ebp - 0A4h]
mov eax, ecx
mov ecx, ebx
push eax
call @06
mov ecx, ebx
call @07
mov ecx, ebx
call @08
pop edi
pop esi
pop ebx
leave
ret 1Ch
@32:
push ebp
mov ebp, esp
push ebx
mov ebx, dword[ebp + 8h]
push esi
push edi
mov esi, edx
mov dword[ebp + 0Ch], 0Ah
mov edi, ecx
neg ebx
sub edi, esi
@33:
mov eax, dword[esi + edi]
mov ecx, dword[esi]
xor ecx, eax
and ecx, ebx
xor eax, ecx
cdq
mov dword[esi + edi], eax
mov dword[esi + edi + 4h], edx
mov eax, dword[esi]
xor eax, ecx
sub dword[ebp + 0Ch], 1h
cdq
mov dword[esi], eax
lea esi, [esi + 8h]
mov dword[esi - 4h], edx
jne @33
pop edi
pop esi
pop ebx
pop ebp
ret 8h
@34:
push ebp
mov ebp, esp
sub esp, 4FCh
push ebx
push esi
push edi
mov edi, 90h
mov dword[ebp - 34h], edx
push edi
xor esi, esi
mov dword[ebp - 30h], ecx
lea eax, [ebp - 328h]
push esi
push eax
call @45
add esp, 0Ch
mov dword[ebp - 0CCh], esi
xor ebx, ebx
lea eax, [ebp - 0C8h]
inc ebx
mov dword[ebp - 0D0h], ebx
push edi
push esi
push eax
call @45
add esp, 0Ch
mov dword[ebp - 168h], ebx
lea eax, [ebp - 160h]
mov dword[ebp - 164h], esi
push edi
push esi
push eax
call @45
add esp, 0Ch
lea eax, [ebp - 3C8h]
add edi, 8h
push edi
push esi
push eax
call @45
lea eax, [ebp - 330h]
add esp, 0Ch
mov dword[ebp - 18h], eax
lea esi, [ebp - 168h]
lea eax, [ebp - 0D0h]
mov dword[ebp - 20h], esi
mov dword[ebp - 10h], eax
xor esi, esi
lea eax, [ebp - 3C8h]
push edi
mov dword[ebp - 8h], eax
lea eax, [ebp - 460h]
push esi
push eax
call @45
add esp, 0Ch
mov dword[ebp - 200h], ebx
lea eax, [ebp - 1F8h]
mov dword[ebp - 1FCh], esi
push 90h
push esi
push eax
call @45
add esp, 0Ch
lea eax, [ebp - 4F8h]
push edi
push esi
push eax
call @45
add esp, 0Ch
mov dword[ebp - 298h], ebx
lea eax, [ebp - 290h]
mov dword[ebp - 294h], esi
push 90h
push esi
push eax
call @45
lea eax, [ebp - 460h]
add esp, 0Ch
mov dword[ebp - 0Ch], eax
lea eax, [ebp - 200h]
mov dword[ebp - 1Ch], eax
lea eax, [ebp - 4F8h]
mov dword[ebp - 4h], eax
mov esi, dword[ebp + 0Ch]
lea eax, [ebp - 298h]
mov dword[ebp - 14h], eax
lea edi, [ebp - 330h]
mov eax, dword[ebp + 8h]
push 14h
pop ecx
rep movsd
lea ebx, [eax + 1Fh]
mov dword[ebp - 2Ch], 20h
mov dword[ebp - 28h], ebx
lea ecx, [ebp - 330h]
@35:
mov al, byte[ebx]
mov ebx, dword[ebp - 20h]
mov byte[ebp + 0Bh], al
mov dword[ebp - 24h], 8h
@36:
shr al, 7h
movzx eax, al
cdq
mov esi, edx
mov edi, eax
push esi
mov edx, ecx
mov ecx, ebx
push edi
call @32
mov edx, dword[ebp - 10h]
mov ecx, dword[ebp - 8h]
push esi
push edi
call @32
push dword[ebp + 0Ch]
mov edx, dword[ebp - 14h]
push dword[ebp - 10h]
mov ecx, dword[ebp - 4h]
push dword[ebp - 18h]
push dword[ebp - 8h]
push ebx
push dword[ebp - 1Ch]
push dword[ebp - 0Ch]
call @30
mov edx, dword[ebp - 0Ch]
mov ecx, dword[ebp - 4h]
push esi
push edi
call @32
mov ecx, dword[ebp - 14h]
push esi
mov esi, dword[ebp - 1Ch]
mov edx, esi
push edi
call @32
mov edx, dword[ebp - 14h]
mov eax, ebx
mov ebx, dword[ebp - 4h]
mov ecx, dword[ebp - 0Ch]
mov dword[ebp - 4h], eax
mov eax, dword[ebp - 8h]
mov dword[ebp - 14h], eax
mov eax, dword[ebp - 18h]
mov dword[ebp - 0Ch], eax
mov eax, dword[ebp - 10h]
mov dword[ebp - 1Ch], eax
mov al, byte[ebp + 0Bh]
add al, al
mov dword[ebp - 8h], edx
sub dword[ebp - 24h], 1h
mov dword[ebp - 18h], ecx
mov dword[ebp - 10h], esi
mov byte[ebp + 0Bh], al
jne @36
mov dword[ebp - 20h], ebx
mov ebx, dword[ebp - 28h]
dec ebx
sub dword[ebp - 2Ch], 1h
mov dword[ebp - 28h], ebx
jne @35
mov esi, dword[ebp - 20h]
mov edi, dword[ebp - 30h]
push 14h
pop ecx
rep movsd
mov edi, dword[ebp - 34h]
mov esi, edx
push 14h
pop ecx
rep movsd
pop edi
pop esi
pop ebx
leave
ret 8h
@37:
push ebp
mov ebp, esp
sub esp, 194h
push ebx
push esi
mov ebx, ecx
mov esi, edx
push edi
lea ecx, [ebp - 0F0h]
call @12
lea edx, [ebp - 0F0h]
lea ecx, [ebp - 0A0h]
call @12
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
push esi
lea edx, [ebp - 50h]
lea ecx, [ebp - 140h]
call @10
lea eax, [ebp - 0F0h]
push eax
lea edx, [ebp - 140h]
lea ecx, [ebp - 190h]
call @10
lea edx, [ebp - 190h]
lea ecx, [ebp - 50h]
call @12
lea eax, [ebp - 140h]
push eax
lea edx, [ebp - 50h]
lea ecx, [ebp - 0F0h]
call @10
lea edx, [ebp - 0F0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
lea eax, [ebp - 0F0h]
push eax
lea edx, [ebp - 50h]
lea ecx, [ebp - 140h]
call @10
lea edx, [ebp - 140h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
push 4h
pop edi
mov esi, edi
@38:
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
sub esi, 1h
jne @38
lea eax, [ebp - 140h]
push eax
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 0F0h]
call @10
lea edx, [ebp - 0F0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
push 9h
pop esi
@39:
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
sub esi, 1h
jne @39
lea eax, [ebp - 0F0h]
push eax
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @10
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
@40:
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
sub edi, 1h
jne @40
lea eax, [ebp - 140h]
push eax
lea edx, [ebp - 50h]
lea ecx, [ebp - 0F0h]
call @10
lea edx, [ebp - 0F0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
push 18h
pop esi
mov edi, esi
@41:
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
sub edi, 1h
jne @41
lea eax, [ebp - 0F0h]
push eax
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 140h]
call @10
lea edx, [ebp - 140h]
lea ecx, [ebp - 0A0h]
call @12
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
push 31h
pop edi
@42:
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
sub edi, 1h
jne @42
lea eax, [ebp - 140h]
push eax
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @10
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
@43:
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
sub esi, 1h
jne @43
lea eax, [ebp - 0F0h]
push eax
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @10
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
lea edx, [ebp - 0A0h]
lea ecx, [ebp - 50h]
call @12
lea edx, [ebp - 50h]
lea ecx, [ebp - 0A0h]
call @12
lea eax, [ebp - 190h]
mov ecx, ebx
push eax
lea edx, [ebp - 0A0h]
call @10
pop edi
pop esi
pop ebx
leave
ret
@45:
push ebp
mov ebp, esp
push edi
mov ecx, dword[ebp + 0x10]
mov edi, dword[ebp + 0x08]
mov al, byte[ebp + 0x0C]
rep stosb
pop edi
leave
retn
@46:
mov eax, dword[esp + 8h]
mov ecx, dword[esp + 10h]
or ecx, eax
mov ecx, dword[esp + 0Ch]
jne @47
mov eax, dword[esp + 4h]
mul ecx
ret 10h
@47:
push ebx
mul ecx
mov ebx, eax
mov eax, dword[esp + 8h]
mul dword[esp + 14h]
add ebx, eax
mov eax, dword[esp + 8h]
mul ecx
add edx, ebx
pop ebx
ret 10h
main.asm
format pe console
section '.code' import readable writeable executable
include 'win32ax.inc'
library msvcrt, 'msvcrt.dll',\
advapi32, 'advapi32.dll'
import msvcrt,\
printf, 'printf',\
getchar, 'getchar',\
memcmp, 'memcmp'
import advapi32,\
RtlGenRandom, 'SystemFunction036'
include 'curve25519.asm'
proc print, lab, buf
locals
frmt db '%02X', 0
endl
cinvoke printf, [lab]
mov esi, [buf]
xor ecx, ecx
@@: movzx eax, byte[esi]
push ecx
cinvoke printf, addr frmt, eax
pop ecx
inc ecx
inc esi
cmp ecx, 32
jne @b
cinvoke printf, next_line
ret
endp
proc rand_private, buf
locals
pRandomBuffer rd 1
endl
mov edi, [buf]
xor ecx, ecx
@@: push ecx
invoke RtlGenRandom, addr pRandomBuffer, 4
cmp eax, 0
je .err
mov eax, [pRandomBuffer]
xor edx, edx
mov ecx, 255
div ecx
mov eax, edx
jmp .fin
.err:
xor eax, eax
dec eax
.fin:
mov byte[edi], al
pop ecx
inc edi
inc ecx
cmp ecx, 32
jl @b
mov esi, [buf]
and byte[esi], 248
mov dl, byte[esi + 31]
and dl, 127
or dl, 64
mov byte[esi + 31], dl
ret
endp
entry $
xor ecx, ecx
@@: push ecx
stdcall rand_private, private_key_1
stdcall rand_private, private_key_2
stdcall curve25519, public_key_1, private_key_1, basepoint
stdcall curve25519, public_key_2, private_key_2, basepoint
stdcall curve25519, shared_key_1, private_key_1, public_key_2
stdcall curve25519, shared_key_2, private_key_2, public_key_1
; stdcall print, priv, private_key_1
; stdcall print, priv, private_key_2
; cinvoke printf, next_line
; stdcall print, publ, public_key_1
; stdcall print, publ, public_key_2
; cinvoke printf, next_line
cinvoke memcmp, shared_key_1, shared_key_2, 32
cmp eax, 0
jne not_eq
; stdcall print, shar, shared_key_1
; stdcall print, shar, shared_key_2
; cinvoke printf, next_line
cinvoke printf, equally
jmp fin
not_eq:
cinvoke printf, not_equal
cinvoke getchar
fin:
pop ecx
inc ecx
cmp ecx, 1000
jl @b
cinvoke printf, finish
cinvoke getchar
xor eax, eax
ret
equally db 'memcmp: equally', 13, 10, 0
not_equal db 'memcmp: not equal', 13, 10, 0
priv db 'private: ', 0
publ db ' public: ', 0
shar db ' shared: ', 0
finish db 13, 10, 'finish ok!', 13, 10, 0
next_line db 13, 10, 0
basepoint db 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
private_key_1 rb 32
private_key_2 rb 32
public_key_1 rb 32
public_key_2 rb 32
shared_key_1 rb 32
shared_key_2 rb 32
Результат:
private: 886F833AA015C3956F01B69AC6FCAF08C65A1D956C7B0431681A5AAA149BE25C
private: 48FC11C04E64CC3D35BA7B71440F2C27D61100E74AB1382BB32F4D949D860574public: 720885C1CB636BE169C30DD5C4D58306AC1E1F49BB36AEBC8912511A467BAC3E
public: F9D27D035BAD8F14D91C88C94311F3C3C273A6260A9919E9B832A1DD25E8D808shared: 8F8900C304DD9CFB14CAC630B6424AEE5505DBDD3EFD8476F08106FB40EE7C37
shared: 8F8900C304DD9CFB14CAC630B6424AEE5505DBDD3EFD8476F08106FB40EE7C37