1

Тема: [FASM] aes256 (cbc, with/without tables)

Черговий ріп.

aes256 (without tables).asm

    use32

    AES_ENCRYPT = 0
    AES_DECRYPT = 1

aes256_cbc:
    push ebp
    mov ebp, esp
    mov eax, dword[ebp + 1Ch]
    sub eax, 0h
    je @02
    sub eax, 1h
    jne @03
    push dword[ebp + 18h]
    mov edx, dword[ebp + 0Ch]
    push dword[ebp + 14h]
    mov ecx, dword[ebp + 8h]
    push dword[ebp + 10h]
    call @48
    jmp @03

@02:
    push dword[ebp + 18h]
    mov edx, dword[ebp + 0Ch]
    push dword[ebp + 14h]
    mov ecx, dword[ebp + 8h]
    push dword[ebp + 10h]
    call @42

@03:
    pop ebp
    ret 18h

@04:
    mov dl, cl
    shr dl, 1h
    or dl, cl
    shr dl, 1h
    mov al, dl
    shr al, 2h
    or dl, al
    movzx ecx, dl
    mov eax, ecx
    shr eax, 4h
    or eax, ecx
    inc eax
    sar eax, 1h
    ret

@05:
    push ebp
    mov ebp, esp
    push ecx
    mov al, cl
    mov byte[ebp - 4h], 1Bh
    push ebx
    mov byte[ebp - 1h], al
    call @04
    mov cl, byte[ebp - 1h]
    mov bl, al
    mov byte[ebp - 3h], 0h
    mov al, 1h
    mov byte[ebp - 2h], al
    mov bh, 80h
    cmp cl, 2h
    jae @06
    mov al, cl
    jmp @14

@06:
    push esi
    test bl, bl
    je @13

@07:
    cmp bh, bl
    jb @09
    movzx esi, bl

@08:
    movzx eax, bh
    cdq
    idiv esi
    mov bh, byte[ebp - 4h]
    movzx ecx, cl
    movzx edx, al
    imul edx, ecx
    movzx ecx, byte[ebp - 2h]
    movzx eax, al
    imul ecx, eax
    xor bh, dl
    mov byte[ebp - 4h], bh
    xor byte[ebp - 3h], cl
    mov cl, bh
    call @04
    mov cl, byte[ebp - 1h]
    mov bh, al
    cmp bh, bl
    jae @08

@09:
    test bh, bh
    je @12
    cmp bl, bh
    jb @11
    movzx esi, bh

@10:
    movzx eax, bl
    cdq
    idiv esi
    movzx ecx, byte[ebp - 4h]
    mov bl, byte[ebp - 1h]
    movzx edx, al
    imul edx, ecx
    movzx ecx, byte[ebp - 3h]
    movzx eax, al
    imul ecx, eax
    xor bl, dl
    mov byte[ebp - 1h], bl
    xor byte[ebp - 2h], cl
    mov cl, bl
    call @04
    mov bl, al
    cmp bl, bh
    jae @10

@11:
    mov cl, byte[ebp - 1h]
    test bl, bl
    jne @07
    mov al, byte[ebp - 2h]
    jmp @13

@12:
    mov al, byte[ebp - 3h]

@13:
    pop esi

@14:
    pop ebx
    leave
    ret

@15:
    movzx ecx, cl
    lea eax, [ecx + ecx]
    xor eax, ecx
    add eax, eax
    xor eax, ecx
    add eax, eax
    xor eax, ecx
    add eax, eax
    xor ecx, eax
    mov eax, ecx
    xor eax, 00006300h
    shr eax, 8h
    xor eax, ecx
    ret

@16:
    movzx eax, cl
    mov ecx, eax
    shl ecx, 3h
    xor ecx, eax
    shl ecx, 2h
    xor ecx, eax
    add ecx, ecx
    mov eax, ecx
    xor eax, 00000500h
    shr eax, 8h
    xor eax, ecx
    ret

@17:
    push ebp
    mov ebp, esp
    push esi
    mov esi, dword[ebp + 8h]
    sub edx, esi
    push edi
    push 4h
    sub ecx, esi
    pop edi

@18:
    mov eax, dword[esi + edx]
    xor eax, dword[esi]
    mov dword[esi + ecx], eax
    lea esi, [esi + 4h]
    sub edi, 1h
    jne @18
    pop edi
    pop esi
    pop ebp
    ret 4h

@19:
    push esi
    push 4h
    sub edx, ecx
    pop esi

@20:
    mov eax, dword[ecx + edx]
    xor dword[ecx], eax
    lea ecx, [ecx + 4h]
    sub esi, 1h
    jne @20
    pop esi
    ret

@21:
    push ebx
    push esi
    mov esi, ecx
    mov cl, byte[esi]
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 4h]
    mov byte[esi], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 8h]
    mov byte[esi + 4h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 0Ch]
    mov byte[esi + 8h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 5h]
    mov bl, byte[esi + 1h]
    mov byte[esi + 0Ch], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 9h]
    mov byte[esi + 1h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 0Dh]
    mov byte[esi + 5h], al
    call @05
    mov cl, al
    call @15
    mov cl, bl
    mov byte[esi + 9h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 0Ah]
    mov bl, byte[esi + 2h]
    mov byte[esi + 0Dh], al
    call @05
    mov cl, al
    call @15
    mov cl, bl
    mov byte[esi + 2h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 0Eh]
    mov bl, byte[esi + 6h]
    mov byte[esi + 0Ah], al
    call @05
    mov cl, al
    call @15
    mov cl, bl
    mov byte[esi + 6h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 0Bh]
    mov bl, byte[esi + 0Fh]
    mov byte[esi + 0Eh], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 7h]
    mov byte[esi + 0Fh], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[esi + 3h]
    mov byte[esi + 0Bh], al
    call @05
    mov cl, al
    call @15
    mov cl, bl
    mov byte[esi + 7h], al
    call @05
    mov cl, al
    call @15
    mov byte[esi + 3h], al
    pop esi
    pop ebx
    ret

@22:
    push ebx
    push esi
    mov esi, ecx
    mov cl, byte[esi]
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 4h]
    mov byte[esi], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 8h]
    mov byte[esi + 4h], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 0Ch]
    mov byte[esi + 8h], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 9h]
    mov bl, byte[esi + 0Dh]
    mov byte[esi + 0Ch], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 5h]
    mov byte[esi + 0Dh], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 1h]
    mov byte[esi + 9h], al
    call @16
    mov cl, al
    call @05
    mov cl, bl
    mov byte[esi + 5h], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 0Ah]
    mov bl, byte[esi + 2h]
    mov byte[esi + 1h], al
    call @16
    mov cl, al
    call @05
    mov cl, bl
    mov byte[esi + 2h], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 0Eh]
    mov bl, byte[esi + 6h]
    mov byte[esi + 0Ah], al
    call @16
    mov cl, al
    call @05
    mov cl, bl
    mov byte[esi + 6h], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 7h]
    mov bl, byte[esi + 3h]
    mov byte[esi + 0Eh], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 0Bh]
    mov byte[esi + 3h], al
    call @16
    mov cl, al
    call @05
    mov cl, byte[esi + 0Fh]
    mov byte[esi + 7h], al
    call @16
    mov cl, al
    call @05
    mov cl, bl
    mov byte[esi + 0Bh], al
    call @16
    mov cl, al
    call @05
    mov byte[esi + 0Fh], al
    pop esi
    pop ebx
    ret

@23:
    push ebp
    mov ebp, esp
    sub esp, 1Ch
    push ebx
    push esi
    push edi
    mov esi, ecx
    mov dword[ebp - 0Ch], ecx
    lea edi, [ebp - 1Ch]
    movsd
    movsd
    movsd
    movsd
    mov cl, byte[ebp - 1Ch]
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 17h]
    mov bl, al
    mov byte[ebp - 3h], bl
    call @05
    mov cl, al
    call @15
    mov cl, bl
    mov dl, al
    shr cl, 7h
    movzx ecx, cl
    imul eax, ecx, 1Bh
    mov cl, dl
    shr cl, 7h
    movzx ecx, cl
    imul ebx, ecx, 1Bh
    mov cl, byte[ebp - 12h]
    mov byte[ebp - 2h], dl
    mov dword[ebp - 8h], eax
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 0Dh]
    mov byte[ebp - 1h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 2h]
    mov ch, al
    xor cl, byte[ebp - 3h]
    mov esi, dword[ebp - 0Ch]
    add cl, cl
    xor cl, ch
    mov bh, byte[ebp - 3h]
    xor cl, byte[ebp - 1h]
    xor cl, bl
    mov byte[ebp - 4h], ch
    xor cl, byte[ebp - 8h]
    xor cl, byte[ebp - 2h]
    mov byte[esi], cl
    mov cl, byte[ebp - 1h]
    mov al, cl
    shr al, 7h
    movzx eax, al
    imul edx, eax, 1Bh
    mov al, cl
    xor al, byte[ebp - 2h]
    add al, al
    xor al, dl
    xor al, ch
    xor al, cl
    xor al, bl
    mov bl, ch
    xor al, bh
    mov byte[esi + 1h], al
    mov al, bl
    shr al, 7h
    movzx eax, al
    imul ecx, eax, 1Bh
    mov al, bl
    xor al, byte[ebp - 1h]
    add al, al
    xor al, cl
    xor al, dl
    xor al, bl
    xor al, byte[ebp - 2h]
    xor al, bh
    mov byte[esi + 2h], al
    xor bl, bh
    add bl, bl
    xor bl, cl
    mov cl, byte[ebp - 18h]
    xor bl, byte[ebp - 1h]
    xor bl, byte[ebp - 8h]
    xor bl, byte[ebp - 2h]
    xor bl, bh
    mov byte[esi + 3h], bl
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 13h]
    mov bl, al
    mov byte[ebp - 3h], bl
    call @05
    mov cl, al
    call @15
    mov cl, bl
    mov dl, al
    shr cl, 7h
    movzx ecx, cl
    imul eax, ecx, 1Bh
    mov cl, dl
    shr cl, 7h
    movzx ecx, cl
    imul ebx, ecx, 1Bh
    mov cl, byte[ebp - 19h]
    mov byte[ebp - 1h], dl
    mov dword[ebp - 8h], eax
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 0Eh]
    mov byte[ebp - 2h], al
    call @05
    mov cl, al
    call @15
    mov ch, al
    mov cl, byte[ebp - 1h]
    xor cl, byte[ebp - 3h]
    shr al, 7h
    add cl, cl
    movzx eax, al
    xor cl, ch
    xor cl, byte[ebp - 2h]
    imul edx, eax, 1Bh
    xor cl, bl
    mov bh, byte[ebp - 2h]
    mov al, ch
    xor al, byte[ebp - 1h]
    xor cl, byte[ebp - 8h]
    add al, al
    xor cl, byte[ebp - 1h]
    xor al, dl
    mov byte[ebp - 4h], ch
    xor al, ch
    mov byte[esi + 4h], cl
    xor al, byte[ebp - 2h]
    xor al, bl
    xor al, byte[ebp - 3h]
    mov byte[esi + 5h], al
    mov al, bh
    shr al, 7h
    movzx eax, al
    imul ecx, eax, 1Bh
    mov al, byte[ebp - 4h]
    mov ah, byte[ebp - 3h]
    xor al, bh
    add al, al
    xor al, cl
    xor al, dl
    xor al, bh
    xor bh, ah
    xor al, byte[ebp - 1h]
    add bh, bh
    xor bh, cl
    xor al, ah
    xor bh, byte[ebp - 4h]
    xor bh, byte[ebp - 8h]
    mov byte[esi + 6h], al
    xor bh, byte[ebp - 1h]
    mov cl, byte[ebp - 14h]
    xor bh, ah
    mov byte[esi + 7h], bh
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 0Fh]
    mov bl, al
    mov byte[ebp - 1h], bl
    call @05
    mov cl, al
    call @15
    mov cl, bl
    mov dl, al
    shr cl, 7h
    movzx ecx, cl
    imul eax, ecx, 1Bh
    mov cl, dl
    shr cl, 7h
    movzx ecx, cl
    imul ebx, ecx, 1Bh
    mov cl, byte[ebp - 1Ah]
    mov byte[ebp - 2h], dl
    mov dword[ebp - 8h], eax
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 15h]
    mov byte[ebp - 3h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 2h]
    mov ch, al
    xor cl, byte[ebp - 1h]
    add cl, cl
    mov bh, byte[ebp - 1h]
    xor cl, ch
    mov byte[ebp - 4h], ch
    xor cl, byte[ebp - 3h]
    xor cl, bl
    xor cl, byte[ebp - 8h]
    xor cl, byte[ebp - 2h]
    mov byte[esi + 8h], cl
    mov cl, byte[ebp - 3h]
    mov al, cl
    shr al, 7h
    movzx eax, al
    imul edx, eax, 1Bh
    mov al, cl
    xor al, byte[ebp - 2h]
    add al, al
    xor al, dl
    xor al, ch
    xor al, cl
    xor al, bl
    mov bl, ch
    xor al, bh
    mov byte[esi + 9h], al
    mov al, bl
    shr al, 7h
    movzx eax, al
    imul ecx, eax, 1Bh
    mov al, bl
    xor al, byte[ebp - 3h]
    add al, al
    xor al, cl
    xor al, dl
    xor al, bl
    xor bl, bh
    xor al, byte[ebp - 2h]
    add bl, bl
    xor bl, cl
    xor al, bh
    xor bl, byte[ebp - 3h]
    xor bl, byte[ebp - 8h]
    xor bl, byte[ebp - 2h]
    xor bl, bh
    mov byte[esi + 0Ah], al
    mov byte[esi + 0Bh], bl
    mov cl, byte[ebp - 1Bh]
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 10h]
    mov bl, al
    mov byte[ebp - 2h], bl
    call @05
    mov cl, al
    call @15
    mov cl, bl
    mov byte[ebp - 1h], al
    shr cl, 7h
    movzx ecx, cl
    imul ebx, ecx, 1Bh
    mov cl, al
    shr cl, 7h
    movzx ecx, cl
    imul eax, ecx, 1Bh
    mov cl, byte[ebp - 16h]
    mov dword[ebp - 8h], eax
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 11h]
    mov byte[ebp - 3h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 1h]
    mov ch, al
    xor cl, byte[ebp - 2h]
    add cl, cl
    mov bh, byte[ebp - 1h]
    xor cl, ch
    mov byte[ebp - 4h], ch
    xor cl, byte[ebp - 3h]
    xor cl, byte[ebp - 8h]
    xor cl, bl
    xor cl, byte[ebp - 2h]
    mov byte[esi + 0Ch], cl
    mov cl, byte[ebp - 3h]
    mov al, cl
    shr al, 7h
    movzx eax, al
    imul edx, eax, 1Bh
    mov al, cl
    xor al, byte[ebp - 2h]
    add al, al
    pop edi
    xor al, dl
    xor al, ch
    xor al, cl
    xor al, bl
    mov bl, ch
    xor al, bh
    mov byte[esi + 0Dh], al
    mov al, bl
    shr al, 7h
    movzx eax, al
    imul ecx, eax, 1Bh
    mov al, bl
    xor al, byte[ebp - 3h]
    add al, al
    xor al, cl
    xor al, dl
    xor al, bl
    xor bl, bh
    add bl, bl
    xor al, bh
    xor al, byte[ebp - 2h]
    xor bl, cl
    xor bl, byte[ebp - 3h]
    xor bl, byte[ebp - 8h]
    xor bl, bh
    mov byte[esi + 0Eh], al
    xor bl, byte[ebp - 2h]
    mov byte[esi + 0Fh], bl
    pop esi
    pop ebx
    leave
    ret

@24:
    push ebp
    mov ebp, esp
    sub esp, 6Ch
    push ebx
    push esi
    mov esi, ecx
    mov dword[ebp - 50h], ecx
    push edi
    lea edi, [ebp - 6Ch]
    movsd
    movsd
    movsd
    movsd
    mov dh, byte[ebp - 6Ch]
    mov cl, byte[ebp - 69h]
    mov dl, dh
    mov bh, byte[ebp - 6Bh]
    xor cl, dh
    mov bl, byte[ebp - 6Ah]
    xor cl, bh
    xor cl, bl
    shr dl, 5h
    add cl, cl
    mov ch, cl
    mov byte[ebp - 1h], cl
    mov cl, byte[ebp - 69h]
    xor ch, dh
    shr cl, 5h
    xor ch, bl
    mov al, cl
    add ch, ch
    and al, 04h
    mov byte[ebp - 2h], ch
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 34h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 30h], eax
    movzx eax, cl
    mov cl, dh
    imul eax, eax, 1Bh
    shr cl, 6h
    mov dword[ebp - 2Ch], eax
    mov al, dl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 28h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 44h], eax
    movzx eax, cl
    mov cl, bh
    imul eax, eax, 1Bh
    shr cl, 5h
    mov dword[ebp - 40h], eax
    mov al, dl
    and al, 02h
    and dl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 24h], eax
    movzx eax, dl
    imul eax, eax, 1Bh
    mov dword[ebp - 20h], eax
    mov al, cl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 1Ch], eax
    mov al, cl
    and al, 02h
    movzx eax, al
    imul eax, eax, 1Bh
    and cl, 01h
    mov dword[ebp - 18h], eax
    movzx eax, cl
    imul eax, eax, 1Bh
    mov dl, bl
    shr dl, 5h
    mov cl, bl
    shr cl, 6h
    mov dword[ebp - 14h], eax
    mov al, dl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 10h], eax
    mov al, cl
    and cl, 01h
    and al, 02h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 3Ch], eax
    movzx eax, cl
    mov cl, ch
    imul eax, eax, 1Bh
    xor cl, byte[ebp - 6Ch]
    xor cl, byte[ebp - 6Bh]
    add cl, cl
    mov dword[ebp - 38h], eax
    mov al, dl
    and al, 02h
    and dl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 0Ch], eax
    movzx eax, dl
    imul eax, eax, 1Bh
    mov dword[ebp - 8h], eax
    mov al, dh
    shr al, 7h
    movzx eax, al
    imul edx, eax, 1Bh
    mov al, bh
    shr al, 7h
    movzx eax, al
    imul ebx, eax, 1Bh
    mov dword[ebp - 5Ch], edx
    xor cl, bl
    xor cl, dl
    xor cl, byte[ebp - 8h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 38h]
    xor cl, byte[ebp - 3Ch]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 40h]
    xor cl, byte[ebp - 44h]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 69h]
    xor cl, byte[ebp - 6Bh]
    xor cl, byte[ebp - 6Ah]
    call @16
    mov cl, al
    call @05
    mov esi, dword[ebp - 50h]
    mov ch, byte[ebp - 69h]
    mov cl, ch
    shr cl, 6h
    mov byte[esi], al
    mov al, byte[ebp - 1h]
    xor al, ch
    xor al, byte[ebp - 6Bh]
    add al, al
    mov byte[ebp - 1h], al
    mov al, cl
    and al, 02h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 50h], eax
    and cl, 01h
    movzx eax, cl
    mov cl, byte[ebp - 6Bh]
    shr cl, 6h
    imul eax, eax, 1Bh
    mov dword[ebp - 4Ch], eax
    mov al, cl
    and cl, 01h
    and al, 02h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 48h], eax
    movzx eax, cl
    mov cl, byte[ebp - 1h]
    xor cl, byte[ebp - 6Bh]
    xor cl, byte[ebp - 6Ah]
    add cl, cl
    imul edx, eax, 1Bh
    mov al, byte[ebp - 6Ah]
    shr al, 7h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 58h], edx
    xor cl, al
    mov dword[ebp - 54h], eax
    xor cl, dl
    xor cl, byte[ebp - 48h]
    xor cl, byte[ebp - 4Ch]
    xor cl, byte[ebp - 50h]
    xor cl, bl
    xor cl, byte[ebp - 8h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 34h]
    xor cl, ch
    xor cl, byte[ebp - 6Ch]
    xor cl, byte[ebp - 6Ah]
    call @16
    mov cl, al
    call @05
    mov cl, byte[ebp - 69h]
    mov byte[esi + 5h], al
    mov al, cl
    shr al, 7h
    movzx eax, al
    imul ebx, eax, 1Bh
    mov al, byte[ebp - 2h]
    xor al, cl
    xor al, byte[ebp - 6Ah]
    add al, al
    xor al, bl
    xor al, byte[ebp - 54h]
    xor al, byte[ebp - 8h]
    xor al, byte[ebp - 0Ch]
    xor al, byte[ebp - 38h]
    xor al, byte[ebp - 3Ch]
    xor al, byte[ebp - 10h]
    xor al, byte[ebp - 14h]
    xor al, byte[ebp - 18h]
    xor al, byte[ebp - 1Ch]
    xor al, byte[ebp - 20h]
    xor al, byte[ebp - 24h]
    xor al, byte[ebp - 40h]
    xor al, byte[ebp - 44h]
    xor al, byte[ebp - 28h]
    xor al, byte[ebp - 2Ch]
    xor al, byte[ebp - 30h]
    xor al, byte[ebp - 34h]
    xor al, cl
    xor al, byte[ebp - 6Ch]
    xor al, byte[ebp - 6Bh]
    mov cl, al
    call @16
    mov cl, al
    call @05
    mov cl, byte[ebp - 1h]
    xor cl, byte[ebp - 69h]
    xor cl, byte[ebp - 6Ch]
    add cl, cl
    mov byte[esi + 0Ah], al
    xor cl, bl
    xor cl, byte[ebp - 58h]
    xor cl, byte[ebp - 48h]
    xor cl, byte[ebp - 4Ch]
    xor cl, byte[ebp - 50h]
    xor cl, byte[ebp - 5Ch]
    xor cl, byte[ebp - 8h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 6Ch]
    xor cl, byte[ebp - 6Bh]
    xor cl, byte[ebp - 6Ah]
    call @16
    mov cl, al
    call @05
    mov dh, byte[ebp - 68h]
    mov cl, byte[ebp - 65h]
    mov dl, dh
    mov bh, byte[ebp - 67h]
    xor cl, dh
    mov bl, byte[ebp - 66h]
    xor cl, bh
    mov byte[esi + 0Fh], al
    xor cl, bl
    add cl, cl
    shr dl, 5h
    mov ch, cl
    mov byte[ebp - 1h], cl
    mov cl, byte[ebp - 65h]
    xor ch, dh
    shr cl, 5h
    xor ch, bl
    mov al, cl
    add ch, ch
    and al, 04h
    mov byte[ebp - 2h], ch
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 8h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 0Ch], eax
    movzx eax, cl
    mov cl, dh
    imul eax, eax, 1Bh
    shr cl, 6h
    mov dword[ebp - 10h], eax
    mov al, dl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 14h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 44h], eax
    movzx eax, cl
    imul eax, eax, 1Bh
    mov dword[ebp - 48h], eax
    mov al, dl
    and al, 02h
    and dl, 01h
    movzx eax, al
    mov cl, bh
    imul eax, eax, 1Bh
    shr cl, 5h
    mov dword[ebp - 18h], eax
    movzx eax, dl
    mov dl, bl
    imul eax, eax, 1Bh
    shr dl, 5h
    mov dword[ebp - 1Ch], eax
    mov al, cl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 20h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 24h], eax
    movzx eax, cl
    mov cl, bl
    imul eax, eax, 1Bh
    shr cl, 6h
    mov dword[ebp - 28h], eax
    mov al, dl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 2Ch], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 4Ch], eax
    movzx eax, cl
    mov cl, ch
    imul eax, eax, 1Bh
    xor cl, byte[ebp - 68h]
    xor cl, byte[ebp - 67h]
    add cl, cl
    mov dword[ebp - 50h], eax
    mov al, dl
    and al, 02h
    and dl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 30h], eax
    movzx eax, dl
    imul eax, eax, 1Bh
    mov dword[ebp - 34h], eax
    mov al, dh
    shr al, 7h
    movzx eax, al
    imul edx, eax, 1Bh
    mov al, bh
    shr al, 7h
    movzx eax, al
    imul ebx, eax, 1Bh
    mov dword[ebp - 54h], edx
    xor cl, bl
    xor cl, dl
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 50h]
    xor cl, byte[ebp - 4Ch]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 48h]
    xor cl, byte[ebp - 44h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 8h]
    xor cl, byte[ebp - 65h]
    xor cl, byte[ebp - 67h]
    xor cl, byte[ebp - 66h]
    call @16
    mov cl, al
    call @05
    mov ch, byte[ebp - 65h]
    mov byte[esi + 4h], al
    mov cl, ch
    mov al, byte[ebp - 1h]
    shr cl, 6h
    xor al, ch
    xor al, byte[ebp - 67h]
    add al, al
    mov byte[ebp - 1h], al
    mov al, cl
    and cl, 01h
    and al, 02h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 38h], eax
    movzx eax, cl
    mov cl, byte[ebp - 67h]
    shr cl, 6h
    imul eax, eax, 1Bh
    mov dword[ebp - 3Ch], eax
    mov al, cl
    and cl, 01h
    and al, 02h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 40h], eax
    movzx eax, cl
    mov cl, byte[ebp - 1h]
    xor cl, byte[ebp - 67h]
    xor cl, byte[ebp - 66h]
    add cl, cl
    imul edx, eax, 1Bh
    mov al, byte[ebp - 66h]
    shr al, 7h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 58h], edx
    xor cl, al
    mov dword[ebp - 5Ch], eax
    xor cl, dl
    xor cl, byte[ebp - 40h]
    xor cl, byte[ebp - 3Ch]
    xor cl, byte[ebp - 38h]
    xor cl, bl
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 8h]
    xor cl, ch
    xor cl, byte[ebp - 68h]
    xor cl, byte[ebp - 66h]
    call @16
    mov cl, al
    call @05
    mov cl, byte[ebp - 65h]
    mov byte[esi + 9h], al
    mov al, cl
    shr al, 7h
    movzx eax, al
    imul ebx, eax, 1Bh
    mov al, byte[ebp - 2h]
    xor al, cl
    xor al, byte[ebp - 66h]
    add al, al
    xor al, bl
    xor al, byte[ebp - 5Ch]
    xor al, byte[ebp - 34h]
    xor al, byte[ebp - 30h]
    xor al, byte[ebp - 50h]
    xor al, byte[ebp - 4Ch]
    xor al, byte[ebp - 2Ch]
    xor al, byte[ebp - 28h]
    xor al, byte[ebp - 24h]
    xor al, byte[ebp - 20h]
    xor al, byte[ebp - 1Ch]
    xor al, byte[ebp - 18h]
    xor al, byte[ebp - 48h]
    xor al, byte[ebp - 44h]
    xor al, byte[ebp - 14h]
    xor al, byte[ebp - 10h]
    xor al, byte[ebp - 0Ch]
    xor al, byte[ebp - 8h]
    xor al, cl
    xor al, byte[ebp - 68h]
    xor al, byte[ebp - 67h]
    mov cl, al
    call @16
    mov cl, al
    call @05
    mov cl, byte[ebp - 1h]
    xor cl, byte[ebp - 65h]
    xor cl, byte[ebp - 68h]
    add cl, cl
    mov byte[esi + 0Eh], al
    xor cl, bl
    xor cl, byte[ebp - 58h]
    xor cl, byte[ebp - 40h]
    xor cl, byte[ebp - 3Ch]
    xor cl, byte[ebp - 38h]
    xor cl, byte[ebp - 54h]
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 8h]
    xor cl, byte[ebp - 68h]
    xor cl, byte[ebp - 67h]
    xor cl, byte[ebp - 66h]
    call @16
    mov cl, al
    call @05
    mov bh, byte[ebp - 64h]
    mov cl, byte[ebp - 61h]
    mov bl, byte[ebp - 62h]
    xor cl, bh
    xor cl, byte[ebp - 63h]
    xor cl, bl
    mov byte[esi + 3h], al
    add cl, cl
    mov ch, cl
    mov byte[ebp - 1h], cl
    mov cl, byte[ebp - 61h]
    xor ch, bh
    shr cl, 5h
    xor ch, bl
    mov al, cl
    add ch, ch
    and al, 04h
    mov byte[ebp - 2h], ch
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 0Ch], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 10h], eax
    movzx eax, cl
    imul eax, eax, 1Bh
    mov dword[ebp - 14h], eax
    mov dl, bh
    shr dl, 5h
    mov cl, bh
    mov al, dl
    shr cl, 6h
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 18h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 48h], eax
    movzx eax, cl
    imul eax, eax, 1Bh
    mov cl, byte[ebp - 63h]
    shr cl, 5h
    mov dword[ebp - 4Ch], eax
    mov al, dl
    and al, 02h
    and dl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 1Ch], eax
    movzx eax, dl
    mov dl, bl
    imul eax, eax, 1Bh
    shr dl, 5h
    mov dword[ebp - 20h], eax
    mov al, cl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 24h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 28h], eax
    movzx eax, cl
    mov cl, bl
    imul eax, eax, 1Bh
    shr cl, 6h
    mov dword[ebp - 2Ch], eax
    mov al, dl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 30h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 50h], eax
    movzx eax, cl
    imul ebx, eax, 1Bh
    mov al, dl
    and al, 02h
    and dl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 58h], ebx
    mov dword[ebp - 34h], eax
    movzx eax, dl
    imul eax, eax, 1Bh
    mov dword[ebp - 8h], eax
    mov al, byte[ebp - 64h]
    shr al, 7h
    movzx eax, al
    imul edx, eax, 1Bh
    mov al, byte[ebp - 63h]
    shr al, 7h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 38h], edx
    mov dword[ebp - 5Ch], eax
    mov cl, ch
    mov bh, byte[ebp - 63h]
    xor cl, byte[ebp - 64h]
    xor cl, byte[ebp - 63h]
    add cl, cl
    xor cl, al
    xor cl, dl
    xor cl, byte[ebp - 8h]
    xor cl, byte[ebp - 34h]
    xor cl, bl
    mov bl, byte[ebp - 61h]
    xor cl, byte[ebp - 50h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 4Ch]
    xor cl, byte[ebp - 48h]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, bl
    xor cl, bh
    xor cl, byte[ebp - 62h]
    call @16
    mov cl, al
    call @05
    mov byte[esi + 8h], al
    mov cl, bl
    mov al, byte[ebp - 1h]
    xor al, bl
    shr cl, 6h
    xor al, bh
    mov ch, byte[ebp - 62h]
    add al, al
    mov byte[ebp - 1h], al
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 3Ch], eax
    movzx eax, cl
    mov cl, bh
    shr cl, 6h
    imul eax, eax, 1Bh
    mov dword[ebp - 40h], eax
    mov al, cl
    and cl, 01h
    and al, 02h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 44h], eax
    movzx eax, cl
    mov cl, byte[ebp - 1h]
    xor cl, byte[ebp - 63h]
    imul edx, eax, 1Bh
    xor cl, ch
    add cl, cl
    mov al, ch
    shr al, 7h
    movzx eax, al
    imul ebx, eax, 1Bh
    mov dword[ebp - 54h], edx
    xor cl, bl
    xor cl, dl
    xor cl, byte[ebp - 44h]
    xor cl, byte[ebp - 40h]
    xor cl, byte[ebp - 3Ch]
    xor cl, byte[ebp - 5Ch]
    xor cl, byte[ebp - 8h]
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 61h]
    xor cl, byte[ebp - 64h]
    xor cl, ch
    call @16
    mov cl, al
    call @05
    mov dl, byte[ebp - 61h]
    mov cl, byte[ebp - 2h]
    xor cl, dl
    mov byte[esi + 0Dh], al
    xor cl, byte[ebp - 62h]
    mov al, dl
    add cl, cl
    shr al, 7h
    xor cl, bl
    movzx eax, al
    mov ebx, dword[ebp - 8h]
    xor cl, bl
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 58h]
    xor cl, byte[ebp - 50h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 4Ch]
    xor cl, byte[ebp - 48h]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    imul eax, eax, 1Bh
    xor cl, al
    mov dword[ebp - 5Ch], eax
    xor cl, dl
    xor cl, byte[ebp - 64h]
    xor cl, byte[ebp - 63h]
    call @16
    mov cl, al
    call @05
    mov cl, byte[ebp - 1h]
    xor cl, byte[ebp - 61h]
    xor cl, byte[ebp - 64h]
    add cl, cl
    mov byte[esi + 2h], al
    xor cl, byte[ebp - 54h]
    xor cl, byte[ebp - 44h]
    xor cl, byte[ebp - 40h]
    xor cl, byte[ebp - 3Ch]
    xor cl, byte[ebp - 38h]
    xor cl, bl
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 5Ch]
    xor cl, byte[ebp - 64h]
    xor cl, byte[ebp - 63h]
    xor cl, byte[ebp - 62h]
    call @16
    mov cl, al
    call @05
    mov cl, byte[ebp - 5Dh]
    mov dh, byte[ebp - 60h]
    mov byte[esi + 7h], al
    mov al, cl
    mov byte[ebp - 1h], cl
    xor al, dh
    mov bh, byte[ebp - 5Fh]
    mov ch, dh
    xor al, bh
    mov bl, byte[ebp - 5Eh]
    xor al, bl
    shr cl, 5h
    add al, al
    xor ch, bl
    xor ch, al
    mov byte[ebp - 2h], al
    mov al, cl
    mov dl, dh
    and al, 04h
    shr dl, 5h
    movzx eax, al
    add ch, ch
    imul eax, eax, 1Bh
    mov byte[ebp - 3h], ch
    mov dword[ebp - 8h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 0Ch], eax
    movzx eax, cl
    mov cl, dh
    imul eax, eax, 1Bh
    shr cl, 6h
    mov dword[ebp - 10h], eax
    mov al, dl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 14h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 44h], eax
    movzx eax, cl
    mov cl, bh
    imul eax, eax, 1Bh
    shr cl, 5h
    mov dword[ebp - 48h], eax
    mov al, dl
    and al, 02h
    and dl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 18h], eax
    movzx eax, dl
    mov dl, bl
    imul eax, eax, 1Bh
    shr dl, 5h
    mov dword[ebp - 1Ch], eax
    mov al, cl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 20h], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 24h], eax
    movzx eax, cl
    mov cl, bl
    imul eax, eax, 1Bh
    shr cl, 6h
    mov dword[ebp - 28h], eax
    mov al, dl
    and al, 04h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 2Ch], eax
    mov al, cl
    and al, 02h
    movzx eax, al
    and cl, 01h
    imul eax, eax, 1Bh
    mov dword[ebp - 4Ch], eax
    movzx eax, cl
    imul eax, eax, 1Bh
    mov cl, byte[ebp - 60h]
    xor cl, byte[ebp - 5Fh]
    xor cl, ch
    add cl, cl
    xor cl, byte[ebp - 1h]
    mov dword[ebp - 50h], eax
    mov al, dl
    xor cl, byte[ebp - 5Fh]
    and al, 02h
    xor cl, byte[ebp - 5Eh]
    and dl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 30h], eax
    movzx eax, dl
    imul eax, eax, 1Bh
    mov dword[ebp - 34h], eax
    mov al, dh
    shr al, 7h
    movzx eax, al
    imul edx, eax, 1Bh
    mov al, bh
    shr al, 7h
    movzx eax, al
    imul ebx, eax, 1Bh
    mov dword[ebp - 54h], edx
    xor cl, bl
    xor cl, dl
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 50h]
    xor cl, byte[ebp - 4Ch]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 48h]
    xor cl, byte[ebp - 44h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 8h]
    call @16
    mov cl, al
    call @05
    mov cl, byte[ebp - 1h]
    mov byte[esi + 0Ch], al
    shr cl, 6h
    mov al, cl
    mov ch, byte[ebp - 1h]
    and al, 02h
    xor ch, byte[ebp - 5Fh]
    movzx eax, al
    and cl, 01h
    imul eax, eax, 1Bh
    xor ch, byte[ebp - 2h]
    add ch, ch
    mov byte[ebp - 2h], ch
    mov dword[ebp - 38h], eax
    movzx eax, cl
    mov cl, byte[ebp - 5Fh]
    imul eax, eax, 1Bh
    shr cl, 6h
    mov dword[ebp - 3Ch], eax
    mov al, cl
    and al, 02h
    and cl, 01h
    movzx eax, al
    imul eax, eax, 1Bh
    mov dword[ebp - 40h], eax
    movzx eax, cl
    imul edx, eax, 1Bh
    mov al, byte[ebp - 5Eh]
    mov dword[ebp - 58h], edx
    mov cl, byte[ebp - 5Fh]
    xor cl, byte[ebp - 5Eh]
    xor cl, ch
    shr al, 7h
    add cl, cl
    movzx eax, al
    xor cl, byte[ebp - 1h]
    xor cl, byte[ebp - 60h]
    xor cl, byte[ebp - 5Eh]
    imul eax, eax, 1Bh
    xor cl, al
    mov dword[ebp - 5Ch], eax
    xor cl, dl
    xor cl, byte[ebp - 40h]
    xor cl, byte[ebp - 3Ch]
    xor cl, byte[ebp - 38h]
    xor cl, bl
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 8h]
    call @16
    mov cl, al
    call @05
    mov dl, byte[ebp - 1h]
    mov byte[esi + 1h], al
    mov cl, dl
    xor cl, byte[ebp - 5Eh]
    mov al, dl
    xor cl, byte[ebp - 3h]
    add cl, cl
    shr al, 7h
    xor cl, dl
    movzx eax, al
    xor cl, byte[ebp - 60h]
    xor cl, byte[ebp - 5Fh]
    imul ebx, eax, 1Bh
    xor cl, bl
    xor cl, byte[ebp - 5Ch]
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 50h]
    xor cl, byte[ebp - 4Ch]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 48h]
    xor cl, byte[ebp - 44h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 8h]
    call @16
    mov cl, al
    call @05
    mov cl, byte[ebp - 1h]
    xor cl, byte[ebp - 60h]
    xor cl, byte[ebp - 2h]
    add cl, cl
    mov byte[esi + 6h], al
    xor cl, byte[ebp - 60h]
    xor cl, byte[ebp - 5Fh]
    xor cl, byte[ebp - 5Eh]
    xor cl, bl
    xor cl, byte[ebp - 58h]
    xor cl, byte[ebp - 40h]
    xor cl, byte[ebp - 3Ch]
    xor cl, byte[ebp - 38h]
    xor cl, byte[ebp - 54h]
    xor cl, byte[ebp - 34h]
    xor cl, byte[ebp - 30h]
    xor cl, byte[ebp - 2Ch]
    xor cl, byte[ebp - 28h]
    xor cl, byte[ebp - 24h]
    xor cl, byte[ebp - 20h]
    xor cl, byte[ebp - 1Ch]
    xor cl, byte[ebp - 18h]
    xor cl, byte[ebp - 14h]
    xor cl, byte[ebp - 10h]
    xor cl, byte[ebp - 0Ch]
    xor cl, byte[ebp - 8h]
    call @16
    mov cl, al
    call @05
    pop edi
    mov byte[esi + 0Bh], al
    pop esi
    pop ebx
    leave
    ret

aes_set_key:
    push ebp
    mov ebp, esp
    movzx eax, byte[ebp + 0Ch]
    sub esp, 0Ch
    push ebx
    sub eax, 10h
    je @28
    sub eax, 8h
    je @27
    sub eax, 8h
    je @26
    sub eax, 60h
    je @28
    sub eax, 40h
    je @27
    sub eax, 40h
    je @26
    mov eax, dword[ebp + 10h]
    mov byte[eax + 0F0h], 0h
    or al, 0FFh
    jmp @36

@26:
    mov bh, 20h
    jmp @29

@27:
    mov bh, 18h
    jmp @29

@28:
    mov bh, 10h

@29:
    mov ecx, dword[ebp + 8h]
    mov dl, bh
    push esi
    mov esi, dword[ebp + 10h]
    push edi
    test bh, bh
    je @31
    mov edi, esi
    sub edi, ecx

@30:
    mov al, byte[ecx]
    mov byte[ecx + edi], al
    inc ecx
    sub dl, 1h
    jne @30

@31:
    mov cl, bh
    mov byte[ebp - 1h], 1h
    add cl, 1Ch
    shl cl, 2h
    mov al, cl
    mov byte[ebp - 5h], cl
    shr al, 4h
    dec al
    mov byte[esi + 0F0h], al
    mov al, bh
    mov byte[ebp - 3h], al
    cmp bh, cl
    jae @35
    movzx ecx, bh
    xor bl, bl
    mov dword[ebp - 0Ch], ecx
    mov byte[ebp - 4h], bl

@32:
    movzx edi, al
    mov al, byte[esi + edi - 2h]
    mov byte[ebp + 0Fh], al
    mov al, byte[esi + edi - 1h]
    mov byte[ebp + 13h], al
    mov eax, edi
    cdq
    idiv dword[ebp - 0Ch]
    mov cl, byte[esi + edi - 4h]
    mov ch, byte[esi + edi - 3h]
    mov byte[ebp - 2h], cl
    mov byte[ebp + 0Bh], ch
    test edx, edx
    jne @33
    mov bl, cl
    mov cl, ch
    call @05
    mov cl, al
    call @15
    xor al, byte[ebp - 1h]
    mov cl, byte[ebp + 0Fh]
    mov byte[ebp - 2h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp + 13h]
    mov byte[ebp + 0Bh], al
    call @05
    mov cl, al
    call @15
    mov cl, bl
    mov byte[ebp + 0Fh], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp - 1h]
    mov bl, byte[ebp - 4h]
    mov byte[ebp + 13h], al
    mov al, cl
    shr al, 7h
    add cl, cl
    movzx eax, al
    imul eax, eax, 1Bh
    xor cl, al
    mov byte[ebp - 1h], cl
    jmp @34

@33:
    cmp bh, 18h
    jbe @34
    cmp edx, 10h
    jne @34
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp + 0Bh]
    mov byte[ebp - 2h], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp + 0Fh]
    mov byte[ebp + 0Bh], al
    call @05
    mov cl, al
    call @15
    mov cl, byte[ebp + 13h]
    mov byte[ebp + 0Fh], al
    call @05
    mov cl, al
    call @15
    mov byte[ebp + 13h], al

@34:
    movzx ecx, bl
    add bl, 4h
    mov byte[ebp - 4h], bl
    mov al, byte[esi + ecx]
    xor al, byte[ebp - 2h]
    mov byte[esi + edi], al
    mov al, byte[esi + ecx + 1h]
    xor al, byte[ebp + 0Bh]
    mov byte[esi + edi + 1h], al
    mov al, byte[esi + ecx + 2h]
    xor al, byte[ebp + 0Fh]
    mov byte[esi + edi + 2h], al
    mov al, byte[esi + ecx + 3h]
    xor al, byte[ebp + 13h]
    mov byte[esi + edi + 3h], al
    mov al, byte[ebp - 3h]
    add al, 4h
    mov byte[ebp - 3h], al
    cmp al, byte[ebp - 5h]
    jb @32

@35:
    pop edi
    xor al, al
    pop esi

@36:
    pop ebx
    leave
    ret 0Ch

@37:
    push ebp
    mov ebp, esp
    sub esp, 14h
    push ebx
    push esi
    mov esi, dword[ebp + 8h]
    mov dword[ebp - 4h], edx
    mov bl, byte[esi + 0F0h]
    test bl, bl
    je @40
    mov edx, ecx
    lea ecx, [ebp - 14h]
    push esi
    call @17
    mov byte[ebp + 8h], 1h
    cmp bl, 1h
    jbe @39
    dec bl
    movzx eax, bl
    mov ebx, eax
    inc al
    push edi
    lea edi, [esi + 10h]
    mov dword[ebp + 8h], eax

@38:
    lea ecx, [ebp - 14h]
    call @23
    mov edx, edi
    lea ecx, [ebp - 14h]
    call @19
    add edi, 10h
    sub ebx, 1h
    jne @38
    pop edi

@39:
    lea ecx, [ebp - 14h]
    call @21
    mov ecx, dword[ebp + 8h]
    lea edx, [ebp - 14h]
    movzx eax, cl
    mov ecx, dword[ebp - 4h]
    shl eax, 4h
    add eax, esi
    push eax
    call @17
    xor al, al
    jmp @41

@40:
    or al, 0FFh

@41:
    pop esi
    pop ebx
    leave
    ret 4h

@42:
    push ebp
    mov ebp, esp
    push ecx
    push ecx
    mov eax, dword[ebp + 8h]
    mov dword[ebp - 8h], edx
    push ebx
    push esi
    push edi
    mov edi, edx
    test eax, eax
    je @45
    mov ebx, dword[ebp + 0Ch]
    sub ecx, ebx
    mov dword[ebp - 4h], ecx

@43:
    dec eax
    mov ecx, ebx
    mov ebx, dword[ebp - 4h]
    push 4h
    mov dword[ebp + 8h], eax
    pop edx

@44:
    mov eax, dword[ecx + ebx]
    xor dword[ecx], eax
    lea ecx, [ecx + 4h]
    sub edx, 1h
    jne @44
    mov ebx, dword[ebp + 0Ch]
    mov edx, ebx
    push dword[ebp + 10h]
    mov ecx, ebx
    call @37
    test al, al
    jne @47
    add dword[ebp - 4h], 10h
    mov esi, ebx
    mov eax, dword[ebp + 8h]
    movsd
    movsd
    movsd
    movsd
    mov edi, dword[ebp - 8h]
    add edi, 10h
    mov dword[ebp - 8h], edi
    test eax, eax
    jne @43

@45:
    xor al, al

@46:
    pop edi
    pop esi
    pop ebx
    leave
    ret 0Ch

@47:
    mov al, 1h
    jmp @46

@48:
    push ebp
    mov ebp, esp
    sub esp, 30h
    mov eax, dword[ebp + 8h]
    mov dword[ebp - 0Ch], ecx
    push ebx
    mov ebx, edx
    mov edx, ecx
    mov dword[ebp - 8h], ebx
    push esi
    push edi
    test eax, eax
    je @53
    mov ecx, dword[ebp + 0Ch]
    sub ecx, ebx
    mov dword[ebp - 10h], ecx

@49:
    mov esi, edx
    lea edi, [ebp - 30h]
    dec eax
    mov dword[ebp + 8h], eax
    movsd
    movsd
    movsd
    movsd
    mov edi, dword[ebp + 10h]
    mov al, byte[edi + 0F0h]
    mov byte[ebp - 1h], al
    test al, al
    je @55
    movzx eax, al
    lea ecx, [ebp - 20h]
    shl eax, 4h
    add eax, edi
    push eax
    call @17
    lea ecx, [ebp - 20h]
    call @22
    sub byte[ebp - 1h], 1h
    je @51
    mov bl, byte[ebp - 1h]
    movzx esi, bl
    shl esi, 4h
    add esi, edi

@50:
    mov edx, esi
    lea ecx, [ebp - 20h]
    call @19
    lea ecx, [ebp - 20h]
    call @24
    sub esi, 10h
    sub bl, 1h
    jne @50
    mov ebx, dword[ebp - 8h]

@51:
    push edi
    lea edx, [ebp - 20h]
    mov ecx, ebx
    call @17
    mov ecx, dword[ebp - 10h]
    push 4h
    pop edx

@52:
    mov eax, dword[ebx + ecx]
    xor dword[ebx], eax
    add ebx, 4h
    sub edx, 1h
    jne @52
    mov edi, dword[ebp + 0Ch]
    lea esi, [ebp - 30h]
    mov edx, dword[ebp - 0Ch]
    sub ecx, 10h
    mov eax, dword[ebp + 8h]
    add edx, 10h
    mov dword[ebp - 8h], ebx
    movsd
    mov dword[ebp - 0Ch], edx
    mov dword[ebp - 10h], ecx
    movsd
    movsd
    movsd
    test eax, eax
    jne @49

@53:
    xor al, al

@54:
    pop edi
    pop esi
    pop ebx
    leave
    ret 0Ch

@55:
    mov al, 1h
    jmp @54
Подякували: 0xDADA11C7, Pernat1y2

2

Re: [FASM] aes256 (cbc, with/without tables)

aes256 (with tables).asm

    AES_ENCRYPT = 0
    AES_DECRYPT = 1

aes256_cbc:
    push ebp
    mov ebp, esp
    mov eax, dword[ebp + 1Ch]
    sub eax, 0h
    je @02
    sub eax, 1h
    jne @03
    push dword[ebp + 18h]
    mov edx, dword[ebp + 0Ch]
    push dword[ebp + 14h]
    mov ecx, dword[ebp + 8h]
    push dword[ebp + 10h]
    call @34
    jmp @03

@02:
    push dword[ebp + 18h]
    mov edx, dword[ebp + 0Ch]
    push dword[ebp + 14h]
    mov ecx, dword[ebp + 8h]
    push dword[ebp + 10h]
    call @28

@03:
    pop ebp
    ret 18h

@04:
    push ebp
    mov ebp, esp
    push esi
    mov esi, dword[ebp + 8h]
    sub edx, esi
    push edi
    push 4h
    sub ecx, esi
    pop edi

@05:
    mov eax, dword[esi + edx]
    xor eax, dword[esi]
    mov dword[esi + ecx], eax
    lea esi, [esi + 4h]
    sub edi, 1h
    jne @05
    pop edi
    pop esi
    pop ebp
    ret 4h

@06:
    push esi
    push 4h
    sub edx, ecx
    pop esi

@07:
    mov eax, dword[ecx + edx]
    xor dword[ecx], eax
    lea ecx, [ecx + 4h]
    sub esi, 1h
    jne @07
    pop esi
    ret

@08:
    mov edx, ecx
    movzx eax, byte[edx]
    mov cl, byte[edx + 1h]
    mov al, byte[eax + _402310h]
    mov byte[edx], al
    movzx eax, byte[edx + 4h]
    mov al, byte[eax + _402310h]
    mov byte[edx + 4h], al
    movzx eax, byte[edx + 8h]
    mov al, byte[eax + _402310h]
    mov byte[edx + 8h], al
    movzx eax, byte[edx + 0Ch]
    mov al, byte[eax + _402310h]
    mov byte[edx + 0Ch], al
    movzx eax, byte[edx + 5h]
    mov al, byte[eax + _402310h]
    mov byte[edx + 1h], al
    movzx eax, byte[edx + 9h]
    mov al, byte[eax + _402310h]
    mov byte[edx + 5h], al
    movzx eax, byte[edx + 0Dh]
    mov al, byte[eax + _402310h]
    mov byte[edx + 9h], al
    movzx eax, cl
    mov cl, byte[edx + 2h]
    mov al, byte[eax + _402310h]
    mov byte[edx + 0Dh], al
    movzx eax, byte[edx + 0Ah]
    mov al, byte[eax + _402310h]
    mov byte[edx + 2h], al
    movzx eax, cl
    mov cl, byte[edx + 6h]
    mov al, byte[eax + _402310h]
    mov byte[edx + 0Ah], al
    movzx eax, byte[edx + 0Eh]
    mov al, byte[eax + _402310h]
    mov byte[edx + 6h], al
    movzx eax, cl
    mov cl, byte[edx + 0Fh]
    mov al, byte[eax + _402310h]
    mov byte[edx + 0Eh], al
    movzx eax, byte[edx + 0Bh]
    mov al, byte[eax + _402310h]
    mov byte[edx + 0Fh], al
    movzx eax, byte[edx + 7h]
    mov al, byte[eax + _402310h]
    mov byte[edx + 0Bh], al
    movzx eax, byte[edx + 3h]
    mov al, byte[eax + _402310h]
    mov byte[edx + 7h], al
    movzx eax, cl
    mov al, byte[eax + _402310h]
    mov byte[edx + 3h], al
    ret

@09:
    mov edx, ecx
    movzx eax, byte[edx]
    mov cl, byte[edx + 0Dh]
    mov al, byte[eax + _402410h]
    mov byte[edx], al
    movzx eax, byte[edx + 4h]
    mov al, byte[eax + _402410h]
    mov byte[edx + 4h], al
    movzx eax, byte[edx + 8h]
    mov al, byte[eax + _402410h]
    mov byte[edx + 8h], al
    movzx eax, byte[edx + 0Ch]
    mov al, byte[eax + _402410h]
    mov byte[edx + 0Ch], al
    movzx eax, byte[edx + 9h]
    mov al, byte[eax + _402410h]
    mov byte[edx + 0Dh], al
    movzx eax, byte[edx + 5h]
    mov al, byte[eax + _402410h]
    mov byte[edx + 9h], al
    movzx eax, byte[edx + 1h]
    mov al, byte[eax + _402410h]
    mov byte[edx + 5h], al
    movzx eax, cl
    mov cl, byte[edx + 2h]
    mov al, byte[eax + _402410h]
    mov byte[edx + 1h], al
    movzx eax, byte[edx + 0Ah]
    mov al, byte[eax + _402410h]
    mov byte[edx + 2h], al
    movzx eax, cl
    mov cl, byte[edx + 6h]
    mov al, byte[eax + _402410h]
    mov byte[edx + 0Ah], al
    movzx eax, byte[edx + 0Eh]
    mov al, byte[eax + _402410h]
    mov byte[edx + 6h], al
    movzx eax, cl
    mov cl, byte[edx + 3h]
    mov al, byte[eax + _402410h]
    mov byte[edx + 0Eh], al
    movzx eax, byte[edx + 7h]
    mov al, byte[eax + _402410h]
    mov byte[edx + 3h], al
    movzx eax, byte[edx + 0Bh]
    mov al, byte[eax + _402410h]
    mov byte[edx + 7h], al
    movzx eax, byte[edx + 0Fh]
    mov al, byte[eax + _402410h]
    mov byte[edx + 0Bh], al
    movzx eax, cl
    mov al, byte[eax + _402410h]
    mov byte[edx + 0Fh], al
    ret

@10:
    push ebp
    mov ebp, esp
    sub esp, 1Ch
    mov eax, ecx
    mov dword[ebp - 4h], eax
    push ebx
    push esi
    mov esi, eax
    push edi
    lea edi, [ebp - 1Ch]
    movsd
    movsd
    movsd
    movsd
    mov eax, dword[ebp - 1Ch]
    movzx edx, al
    mov eax, dword[ebp - 18h]
    shr eax, 8h
    movzx ebx, al
    mov eax, dword[ebp - 14h]
    mov edi, dword[ebp - 10h]
    shr eax, 10h
    movzx esi, al
    mov al, byte[ebx + _402510h]
    xor al, byte[edx + _402610h]
    shr edi, 18h
    mov ah, byte[esi + _402310h]
    mov dword[ebp - 8h], edx
    mov edx, dword[ebp - 4h]
    mov cl, byte[edi + _402310h]
    xor al, cl
    xor al, ah
    mov byte[edx], al
    mov edx, dword[ebp - 8h]
    mov al, byte[esi + _402510h]
    xor al, byte[ebx + _402610h]
    mov dl, byte[edx + _402310h]
    xor al, dl
    xor al, cl
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 1h], al
    mov cl, byte[ebx + _402310h]
    mov al, byte[edi + _402510h]
    xor al, byte[esi + _402610h]
    mov ebx, dword[ebp - 4h]
    xor al, cl
    xor al, dl
    mov edx, dword[ebp - 8h]
    mov byte[ebx + 2h], al
    mov al, byte[edi + _402610h]
    xor al, byte[edx + _402510h]
    xor al, cl
    mov edi, dword[ebp - 1Ch]
    xor al, ah
    shr edi, 18h
    mov byte[ebx + 3h], al
    mov eax, dword[ebp - 18h]
    movzx edx, al
    mov eax, dword[ebp - 14h]
    mov bl, byte[edi + _402310h]
    shr eax, 8h
    movzx ecx, al
    mov eax, dword[ebp - 10h]
    shr eax, 10h
    movzx esi, al
    mov al, byte[ecx + _402510h]
    xor al, byte[edx + _402610h]
    mov dword[ebp - 8h], edx
    mov ah, byte[esi + _402310h]
    mov edx, dword[ebp - 4h]
    xor al, ah
    xor al, bl
    mov byte[edx + 4h], al
    mov edx, dword[ebp - 8h]
    mov al, byte[esi + _402510h]
    xor al, byte[ecx + _402610h]
    mov cl, byte[ecx + _402310h]
    mov dl, byte[edx + _402310h]
    xor al, dl
    xor al, bl
    mov ebx, dword[ebp - 4h]
    mov byte[ebx + 5h], al
    mov al, byte[esi + _402610h]
    xor al, byte[edi + _402510h]
    xor al, cl
    xor al, dl
    mov edx, dword[ebp - 8h]
    mov byte[ebx + 6h], al
    mov al, byte[edi + _402610h]
    mov edi, dword[ebp - 18h]
    xor al, byte[edx + _402510h]
    xor al, cl
    shr edi, 18h
    xor al, ah
    mov dword[ebp - 8h], edi
    mov byte[ebx + 7h], al
    mov eax, dword[ebp - 1Ch]
    shr eax, 10h
    movzx esi, al
    mov eax, dword[ebp - 14h]
    movzx edx, al
    mov eax, dword[ebp - 10h]
    shr eax, 8h
    movzx ecx, al
    mov bl, byte[edi + _402310h]
    mov bh, byte[esi + _402310h]
    mov edi, dword[ebp - 4h]
    mov al, byte[ecx + _402510h]
    xor al, byte[edx + _402610h]
    xor al, bl
    mov dword[ebp - 0Ch], edx
    mov dl, byte[edx + _402310h]
    xor al, bh
    mov byte[edi + 8h], al
    mov al, byte[ecx + _402610h]
    xor al, byte[esi + _402510h]
    xor al, dl
    mov cl, byte[ecx + _402310h]
    xor al, bl
    mov byte[edi + 9h], al
    mov edi, dword[ebp - 8h]
    mov al, byte[edi + _402510h]
    xor al, byte[esi + _402610h]
    xor al, cl
    xor al, dl
    mov edx, dword[ebp - 4h]
    mov byte[edx + 0Ah], al
    mov edx, dword[ebp - 0Ch]
    mov al, byte[edi + _402610h]
    xor al, byte[edx + _402510h]
    mov edx, dword[ebp - 4h]
    xor al, cl
    mov ecx, dword[ebp - 10h]
    xor al, bh
    movzx ebx, cl
    mov ecx, dword[ebp - 14h]
    mov byte[edx + 0Bh], al
    mov eax, dword[ebp - 1Ch]
    shr eax, 8h
    movzx edi, al
    mov eax, dword[ebp - 18h]
    shr eax, 10h
    movzx esi, al
    mov al, byte[ebx + _402610h]
    xor al, byte[edi + _402510h]
    shr ecx, 18h
    mov ah, byte[esi + _402310h]
    mov dword[ebp - 0Ch], ecx
    mov cl, byte[ecx + _402310h]
    xor al, cl
    xor al, ah
    mov byte[edx + 0Ch], al
    mov al, byte[esi + _402510h]
    xor al, byte[edi + _402610h]
    mov dl, byte[ebx + _402310h]
    xor al, dl
    xor al, cl
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 0Dh], al
    mov cl, byte[edi + _402310h]
    mov edi, dword[ebp - 0Ch]
    mov al, byte[edi + _402510h]
    xor al, byte[esi + _402610h]
    xor al, cl
    xor al, dl
    mov edx, dword[ebp - 4h]
    mov byte[edx + 0Eh], al
    mov al, byte[edi + _402610h]
    xor al, byte[ebx + _402510h]
    pop edi
    xor al, cl
    xor al, ah
    pop esi
    mov byte[edx + 0Fh], al
    pop ebx
    leave
    ret

@11:
    push ebp
    mov ebp, esp
    sub esp, 14h
    mov eax, ecx
    push ebx
    push esi
    mov esi, eax
    mov dword[ebp - 4h], eax
    push edi
    lea edi, [ebp - 14h]
    movsd
    movsd
    movsd
    movsd
    mov edx, dword[ebp - 14h]
    mov ebx, edx
    movzx esi, dl
    mov eax, edx
    shr eax, 10h
    movzx edi, al
    shr edx, 8h
    movzx eax, byte[esi + _402110h]
    movzx edx, dl
    shr ebx, 18h
    movzx ecx, byte[edx + _402710h]
    xor ecx, eax
    movzx eax, byte[edi + _402210h]
    xor ecx, eax
    movzx eax, byte[ebx + _402010h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx], al
    movzx eax, byte[esi + _402010h]
    movzx ecx, byte[edx + _402110h]
    xor ecx, eax
    movzx eax, byte[edi + _402710h]
    xor ecx, eax
    movzx eax, byte[ebx + _402210h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 5h], al
    movzx eax, byte[esi + _402210h]
    movzx ecx, byte[edx + _402010h]
    xor ecx, eax
    movzx eax, byte[edi + _402110h]
    xor ecx, eax
    movzx eax, byte[ebx + _402710h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 0Ah], al
    movzx eax, byte[esi + _402710h]
    movzx ecx, byte[edx + _402210h]
    xor ecx, eax
    movzx eax, byte[edi + _402010h]
    xor ecx, eax
    movzx eax, byte[ebx + _402110h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 0Fh], al
    mov ecx, dword[ebp - 10h]
    mov ebx, ecx
    movzx esi, cl
    mov eax, ecx
    shr ecx, 8h
    shr eax, 10h
    movzx edx, cl
    movzx edi, al
    movzx eax, byte[esi + _402110h]
    shr ebx, 18h
    movzx ecx, byte[edx + _402710h]
    xor ecx, eax
    movzx eax, byte[edi + _402210h]
    xor ecx, eax
    movzx eax, byte[ebx + _402010h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 4h], al
    movzx ecx, byte[edx + _402110h]
    movzx eax, byte[esi + _402010h]
    xor ecx, eax
    movzx eax, byte[edi + _402710h]
    xor ecx, eax
    movzx eax, byte[ebx + _402210h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 9h], al
    movzx eax, byte[esi + _402210h]
    movzx ecx, byte[edx + _402010h]
    xor ecx, eax
    movzx eax, byte[edi + _402110h]
    xor ecx, eax
    movzx eax, byte[ebx + _402710h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 0Eh], al
    movzx eax, byte[esi + _402710h]
    movzx ecx, byte[edx + _402210h]
    xor ecx, eax
    movzx eax, byte[edi + _402010h]
    xor ecx, eax
    movzx eax, byte[ebx + _402110h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 3h], al
    mov ecx, dword[ebp - 0Ch]
    mov ebx, ecx
    movzx esi, cl
    mov eax, ecx
    shr ecx, 8h
    movzx edx, cl
    shr eax, 10h
    movzx edi, al
    movzx eax, byte[esi + _402110h]
    movzx ecx, byte[edx + _402710h]
    xor ecx, eax
    shr ebx, 18h
    movzx eax, byte[edi + _402210h]
    xor ecx, eax
    movzx eax, byte[ebx + _402010h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 8h], al
    movzx eax, byte[esi + _402010h]
    movzx ecx, byte[edx + _402110h]
    xor ecx, eax
    movzx eax, byte[edi + _402710h]
    xor ecx, eax
    movzx eax, byte[ebx + _402210h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 0Dh], al
    movzx eax, byte[esi + _402210h]
    movzx ecx, byte[edx + _402010h]
    xor ecx, eax
    movzx eax, byte[edi + _402110h]
    xor ecx, eax
    movzx eax, byte[ebx + _402710h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 2h], al
    movzx eax, byte[esi + _402710h]
    movzx ecx, byte[edx + _402210h]
    xor ecx, eax
    movzx eax, byte[edi + _402010h]
    xor ecx, eax
    movzx eax, byte[ebx + _402110h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 7h], al
    mov ecx, dword[ebp - 8h]
    mov ebx, ecx
    shr ebx, 18h
    mov eax, ecx
    movzx esi, cl
    shr ecx, 8h
    movzx edx, cl
    shr eax, 10h
    movzx edi, al
    movzx eax, byte[esi + _402110h]
    movzx ecx, byte[edx + _402710h]
    xor ecx, eax
    movzx eax, byte[edi + _402210h]
    xor ecx, eax
    movzx eax, byte[ebx + _402010h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 0Ch], al
    movzx eax, byte[esi + _402010h]
    movzx ecx, byte[edx + _402110h]
    xor ecx, eax
    movzx eax, byte[edi + _402710h]
    xor ecx, eax
    movzx eax, byte[ebx + _402210h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 1h], al
    movzx eax, byte[esi + _402210h]
    movzx ecx, byte[edx + _402010h]
    xor ecx, eax
    movzx eax, byte[edi + _402110h]
    xor ecx, eax
    movzx eax, byte[ebx + _402710h]
    xor ecx, eax
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 6h], al
    movzx eax, byte[esi + _402710h]
    movzx ecx, byte[edx + _402210h]
    xor ecx, eax
    movzx eax, byte[edi + _402010h]
    xor ecx, eax
    movzx eax, byte[ebx + _402110h]
    xor ecx, eax
    pop edi
    pop esi
    pop ebx
    mov al, byte[ecx + _402410h]
    mov ecx, dword[ebp - 4h]
    mov byte[ecx + 0Bh], al
    leave
    ret

aes_set_key:
    push ebp
    mov ebp, esp
    push ecx
    push ecx
    movzx eax, byte[ebp + 0Ch]
    push ebx
    sub eax, 10h
    je @15
    sub eax, 8h
    je @14
    sub eax, 8h
    je @13
    sub eax, 60h
    je @15
    sub eax, 40h
    je @14
    sub eax, 40h
    je @13
    mov eax, dword[ebp + 10h]
    mov byte[eax + 0F0h], 0h
    or al, 0FFh
    jmp @21

@13:
    mov bl, 20h
    jmp @16

@14:
    mov bl, 18h
    jmp @16

@15:
    mov bl, 10h

@16:
    push esi
    mov esi, dword[ebp + 10h]
    movzx eax, bl
    push eax
    push dword[ebp + 8h]
    mov dword[ebp - 8h], eax
    push esi
    call @42
    mov bh, bl
    mov byte[ebp - 3h], bl
    add bh, 1Ch
    mov byte[ebp - 2h], 1h
    shl bh, 2h
    add esp, 0Ch
    mov al, bh
    shr al, 4h
    dec al
    mov byte[esi + 0F0h], al
    mov al, bl
    cmp bl, bh
    jae @20
    xor ch, ch
    mov byte[ebp - 4h], ch
    push edi

@17:
    movzx edi, al
    mov al, byte[esi + edi - 3h]
    mov byte[ebp + 0Fh], al
    mov al, byte[esi + edi - 2h]
    mov byte[ebp + 13h], al
    mov al, byte[esi + edi - 1h]
    mov byte[ebp + 0Bh], al
    mov eax, edi
    cdq
    idiv dword[ebp - 8h]
    mov cl, byte[esi + edi - 4h]
    mov byte[ebp - 1h], cl
    test edx, edx
    jne @22
    movzx eax, byte[ebp + 0Fh]
    mov dl, byte[ebp - 2h]
    mov al, byte[eax + _402310h]
    xor al, dl
    mov byte[ebp - 1h], al
    movzx eax, byte[ebp + 13h]
    mov al, byte[eax + _402310h]
    mov byte[ebp + 0Fh], al
    movzx eax, byte[ebp + 0Bh]
    mov al, byte[eax + _402310h]
    mov byte[ebp + 13h], al
    movzx eax, cl
    mov al, byte[eax + _402310h]
    mov byte[ebp + 0Bh], al
    mov al, dl
    shr al, 7h
    add dl, dl
    movzx eax, al
    imul eax, eax, 1Bh
    xor dl, al
    mov byte[ebp - 2h], dl

@18:
    mov dl, byte[ebp - 1h]

@19:
    mov ah, byte[ebp + 0Bh]
    movzx ecx, ch
    mov al, byte[esi + ecx]
    xor al, dl
    mov byte[esi + edi], al
    mov al, byte[esi + ecx + 1h]
    xor al, byte[ebp + 0Fh]
    mov byte[esi + edi + 1h], al
    mov al, byte[esi + ecx + 2h]
    xor al, byte[ebp + 13h]
    mov byte[esi + edi + 2h], al
    mov al, byte[esi + ecx + 3h]
    mov ch, byte[ebp - 4h]
    xor al, ah
    mov byte[esi + edi + 3h], al
    add ch, 4h
    mov al, byte[ebp - 3h]
    add al, 4h
    mov byte[ebp - 4h], ch
    mov byte[ebp - 3h], al
    cmp al, bh
    jb @17
    pop edi

@20:
    xor al, al
    pop esi

@21:
    pop ebx
    leave
    ret 0Ch

@22:
    cmp bl, 18h
    jbe @18
    cmp edx, 10h
    jne @18
    movzx eax, cl
    mov dl, byte[eax + _402310h]
    movzx eax, byte[ebp + 0Fh]
    mov al, byte[eax + _402310h]
    mov byte[ebp + 0Fh], al
    movzx eax, byte[ebp + 13h]
    mov al, byte[eax + _402310h]
    mov byte[ebp + 13h], al
    movzx eax, byte[ebp + 0Bh]
    mov al, byte[eax + _402310h]
    mov byte[ebp + 0Bh], al
    jmp @19

@23:
    push ebp
    mov ebp, esp
    sub esp, 14h
    push ebx
    push esi
    mov esi, dword[ebp + 8h]
    mov dword[ebp - 4h], edx
    mov bl, byte[esi + 0F0h]
    test bl, bl
    je @26
    mov edx, ecx
    lea ecx, [ebp - 14h]
    push esi
    call @04
    mov byte[ebp + 8h], 1h
    cmp bl, 1h
    jbe @25
    dec bl
    movzx eax, bl
    mov ebx, eax
    inc al
    push edi
    lea edi, [esi + 10h]
    mov dword[ebp + 8h], eax

@24:
    lea ecx, [ebp - 14h]
    call @10
    mov edx, edi
    lea ecx, [ebp - 14h]
    call @06
    add edi, 10h
    sub ebx, 1h
    jne @24
    pop edi

@25:
    lea ecx, [ebp - 14h]
    call @08
    mov ecx, dword[ebp + 8h]
    lea edx, [ebp - 14h]
    movzx eax, cl
    mov ecx, dword[ebp - 4h]
    shl eax, 4h
    add eax, esi
    push eax
    call @04
    xor al, al
    jmp @27

@26:
    or al, 0FFh

@27:
    pop esi
    pop ebx
    leave
    ret 4h

@28:
    push ebp
    mov ebp, esp
    push ecx
    push ecx
    mov eax, dword[ebp + 8h]
    mov dword[ebp - 8h], edx
    push ebx
    push esi
    push edi
    mov edi, edx
    test eax, eax
    je @31
    mov ebx, dword[ebp + 0Ch]
    sub ecx, ebx
    mov dword[ebp - 4h], ecx

@29:
    dec eax
    mov ecx, ebx
    mov ebx, dword[ebp - 4h]
    push 4h
    mov dword[ebp + 8h], eax
    pop edx

@30:
    mov eax, dword[ecx + ebx]
    xor dword[ecx], eax
    lea ecx, [ecx + 4h]
    sub edx, 1h
    jne @30
    mov ebx, dword[ebp + 0Ch]
    mov edx, ebx
    push dword[ebp + 10h]
    mov ecx, ebx
    call @23
    test al, al
    jne @33
    add dword[ebp - 4h], 10h
    mov esi, ebx
    mov eax, dword[ebp + 8h]
    movsd
    movsd
    movsd
    movsd
    mov edi, dword[ebp - 8h]
    add edi, 10h
    mov dword[ebp - 8h], edi
    test eax, eax
    jne @29

@31:
    xor al, al

@32:
    pop edi
    pop esi
    pop ebx
    leave
    ret 0Ch

@33:
    mov al, 1h
    jmp @32

@34:
    push ebp
    mov ebp, esp
    sub esp, 30h
    mov eax, dword[ebp + 8h]
    mov dword[ebp - 0Ch], ecx
    push ebx
    mov ebx, edx
    mov edx, ecx
    mov dword[ebp - 8h], ebx
    push esi
    push edi
    test eax, eax
    je @39
    mov ecx, dword[ebp + 0Ch]
    sub ecx, ebx
    mov dword[ebp - 10h], ecx

@35:
    mov esi, edx
    lea edi, [ebp - 30h]
    dec eax
    mov dword[ebp + 8h], eax
    movsd
    movsd
    movsd
    movsd
    mov edi, dword[ebp + 10h]
    mov al, byte[edi + 0F0h]
    mov byte[ebp - 1h], al
    test al, al
    je @41
    movzx eax, al
    lea ecx, [ebp - 20h]
    shl eax, 4h
    add eax, edi
    push eax
    call @04
    lea ecx, [ebp - 20h]
    call @09
    sub byte[ebp - 1h], 1h
    je @37
    mov bl, byte[ebp - 1h]
    movzx esi, bl
    shl esi, 4h
    add esi, edi

@36:
    mov edx, esi
    lea ecx, [ebp - 20h]
    call @06
    lea ecx, [ebp - 20h]
    call @11
    sub esi, 10h
    sub bl, 1h
    jne @36
    mov ebx, dword[ebp - 8h]

@37:
    push edi
    lea edx, [ebp - 20h]
    mov ecx, ebx
    call @04
    mov ecx, dword[ebp - 10h]
    push 4h
    pop edx

@38:
    mov eax, dword[ebx + ecx]
    xor dword[ebx], eax
    add ebx, 4h
    sub edx, 1h
    jne @38
    mov edi, dword[ebp + 0Ch]
    lea esi, [ebp - 30h]
    mov edx, dword[ebp - 0Ch]
    sub ecx, 10h
    mov eax, dword[ebp + 8h]
    add edx, 10h
    mov dword[ebp - 8h], ebx
    movsd
    mov dword[ebp - 0Ch], edx
    mov dword[ebp - 10h], ecx
    movsd
    movsd
    movsd
    test eax, eax
    jne @35

@39:
    xor al, al

@40:
    pop edi
    pop esi
    pop ebx
    leave
    ret 0Ch

@41:
    mov al, 1h
    jmp @40

@42:
    push ebp
    mov ebp, esp
    push esi
    push edi
    mov esi, dword[ebp + 0x0C]
    mov edi, dword[ebp + 0x08]
    mov ecx, dword[ebp + 0x10]
    rep movsb
    pop edi
    pop esi
    leave
    retn

_402010h:
      db 000h, 009h, 012h, 01Bh, 024h, 02Dh, 036h, 03Fh, 048h, 041h, 05Ah, 053h, 06Ch, 065h, 07Eh, 077h
      db 090h, 099h, 082h, 08Bh, 0B4h, 0BDh, 0A6h, 0AFh, 0D8h, 0D1h, 0CAh, 0C3h, 0FCh, 0F5h, 0EEh, 0E7h
      db 03Bh, 032h, 029h, 020h, 01Fh, 016h, 00Dh, 004h, 073h, 07Ah, 061h, 068h, 057h, 05Eh, 045h, 04Ch
      db 0ABh, 0A2h, 0B9h, 0B0h, 08Fh, 086h, 09Dh, 094h, 0E3h, 0EAh, 0F1h, 0F8h, 0C7h, 0CEh, 0D5h, 0DCh
      db 076h, 07Fh, 064h, 06Dh, 052h, 05Bh, 040h, 049h, 03Eh, 037h, 02Ch, 025h, 01Ah, 013h, 008h, 001h
      db 0E6h, 0EFh, 0F4h, 0FDh, 0C2h, 0CBh, 0D0h, 0D9h, 0AEh, 0A7h, 0BCh, 0B5h, 08Ah, 083h, 098h, 091h
      db 04Dh, 044h, 05Fh, 056h, 069h, 060h, 07Bh, 072h, 005h, 00Ch, 017h, 01Eh, 021h, 028h, 033h, 03Ah
      db 0DDh, 0D4h, 0CFh, 0C6h, 0F9h, 0F0h, 0EBh, 0E2h, 095h, 09Ch, 087h, 08Eh, 0B1h, 0B8h, 0A3h, 0AAh
      db 0ECh, 0E5h, 0FEh, 0F7h, 0C8h, 0C1h, 0DAh, 0D3h, 0A4h, 0ADh, 0B6h, 0BFh, 080h, 089h, 092h, 09Bh
      db 07Ch, 075h, 06Eh, 067h, 058h, 051h, 04Ah, 043h, 034h, 03Dh, 026h, 02Fh, 010h, 019h, 002h, 00Bh
      db 0D7h, 0DEh, 0C5h, 0CCh, 0F3h, 0FAh, 0E1h, 0E8h, 09Fh, 096h, 08Dh, 084h, 0BBh, 0B2h, 0A9h, 0A0h
      db 047h, 04Eh, 055h, 05Ch, 063h, 06Ah, 071h, 078h, 00Fh, 006h, 01Dh, 014h, 02Bh, 022h, 039h, 030h
      db 09Ah, 093h, 088h, 081h, 0BEh, 0B7h, 0ACh, 0A5h, 0D2h, 0DBh, 0C0h, 0C9h, 0F6h, 0FFh, 0E4h, 0EDh
      db 00Ah, 003h, 018h, 011h, 02Eh, 027h, 03Ch, 035h, 042h, 04Bh, 050h, 059h, 066h, 06Fh, 074h, 07Dh
      db 0A1h, 0A8h, 0B3h, 0BAh, 085h, 08Ch, 097h, 09Eh, 0E9h, 0E0h, 0FBh, 0F2h, 0CDh, 0C4h, 0DFh, 0D6h
      db 031h, 038h, 023h, 02Ah, 015h, 01Ch, 007h, 00Eh, 079h, 070h, 06Bh, 062h, 05Dh, 054h, 04Fh, 046h

_402110h:
      db 000h, 00Eh, 01Ch, 012h, 038h, 036h, 024h, 02Ah, 070h, 07Eh, 06Ch, 062h, 048h, 046h, 054h, 05Ah
      db 0E0h, 0EEh, 0FCh, 0F2h, 0D8h, 0D6h, 0C4h, 0CAh, 090h, 09Eh, 08Ch, 082h, 0A8h, 0A6h, 0B4h, 0BAh
      db 0DBh, 0D5h, 0C7h, 0C9h, 0E3h, 0EDh, 0FFh, 0F1h, 0ABh, 0A5h, 0B7h, 0B9h, 093h, 09Dh, 08Fh, 081h
      db 03Bh, 035h, 027h, 029h, 003h, 00Dh, 01Fh, 011h, 04Bh, 045h, 057h, 059h, 073h, 07Dh, 06Fh, 061h
      db 0ADh, 0A3h, 0B1h, 0BFh, 095h, 09Bh, 089h, 087h, 0DDh, 0D3h, 0C1h, 0CFh, 0E5h, 0EBh, 0F9h, 0F7h
      db 04Dh, 043h, 051h, 05Fh, 075h, 07Bh, 069h, 067h, 03Dh, 033h, 021h, 02Fh, 005h, 00Bh, 019h, 017h
      db 076h, 078h, 06Ah, 064h, 04Eh, 040h, 052h, 05Ch, 006h, 008h, 01Ah, 014h, 03Eh, 030h, 022h, 02Ch
      db 096h, 098h, 08Ah, 084h, 0AEh, 0A0h, 0B2h, 0BCh, 0E6h, 0E8h, 0FAh, 0F4h, 0DEh, 0D0h, 0C2h, 0CCh
      db 041h, 04Fh, 05Dh, 053h, 079h, 077h, 065h, 06Bh, 031h, 03Fh, 02Dh, 023h, 009h, 007h, 015h, 01Bh
      db 0A1h, 0AFh, 0BDh, 0B3h, 099h, 097h, 085h, 08Bh, 0D1h, 0DFh, 0CDh, 0C3h, 0E9h, 0E7h, 0F5h, 0FBh
      db 09Ah, 094h, 086h, 088h, 0A2h, 0ACh, 0BEh, 0B0h, 0EAh, 0E4h, 0F6h, 0F8h, 0D2h, 0DCh, 0CEh, 0C0h
      db 07Ah, 074h, 066h, 068h, 042h, 04Ch, 05Eh, 050h, 00Ah, 004h, 016h, 018h, 032h, 03Ch, 02Eh, 020h
      db 0ECh, 0E2h, 0F0h, 0FEh, 0D4h, 0DAh, 0C8h, 0C6h, 09Ch, 092h, 080h, 08Eh, 0A4h, 0AAh, 0B8h, 0B6h
      db 00Ch, 002h, 010h, 01Eh, 034h, 03Ah, 028h, 026h, 07Ch, 072h, 060h, 06Eh, 044h, 04Ah, 058h, 056h
      db 037h, 039h, 02Bh, 025h, 00Fh, 001h, 013h, 01Dh, 047h, 049h, 05Bh, 055h, 07Fh, 071h, 063h, 06Dh
      db 0D7h, 0D9h, 0CBh, 0C5h, 0EFh, 0E1h, 0F3h, 0FDh, 0A7h, 0A9h, 0BBh, 0B5h, 09Fh, 091h, 083h, 08Dh

_402210h:
      db 000h, 00Dh, 01Ah, 017h, 034h, 039h, 02Eh, 023h, 068h, 065h, 072h, 07Fh, 05Ch, 051h, 046h, 04Bh
      db 0D0h, 0DDh, 0CAh, 0C7h, 0E4h, 0E9h, 0FEh, 0F3h, 0B8h, 0B5h, 0A2h, 0AFh, 08Ch, 081h, 096h, 09Bh
      db 0BBh, 0B6h, 0A1h, 0ACh, 08Fh, 082h, 095h, 098h, 0D3h, 0DEh, 0C9h, 0C4h, 0E7h, 0EAh, 0FDh, 0F0h
      db 06Bh, 066h, 071h, 07Ch, 05Fh, 052h, 045h, 048h, 003h, 00Eh, 019h, 014h, 037h, 03Ah, 02Dh, 020h
      db 06Dh, 060h, 077h, 07Ah, 059h, 054h, 043h, 04Eh, 005h, 008h, 01Fh, 012h, 031h, 03Ch, 02Bh, 026h
      db 0BDh, 0B0h, 0A7h, 0AAh, 089h, 084h, 093h, 09Eh, 0D5h, 0D8h, 0CFh, 0C2h, 0E1h, 0ECh, 0FBh, 0F6h
      db 0D6h, 0DBh, 0CCh, 0C1h, 0E2h, 0EFh, 0F8h, 0F5h, 0BEh, 0B3h, 0A4h, 0A9h, 08Ah, 087h, 090h, 09Dh
      db 006h, 00Bh, 01Ch, 011h, 032h, 03Fh, 028h, 025h, 06Eh, 063h, 074h, 079h, 05Ah, 057h, 040h, 04Dh
      db 0DAh, 0D7h, 0C0h, 0CDh, 0EEh, 0E3h, 0F4h, 0F9h, 0B2h, 0BFh, 0A8h, 0A5h, 086h, 08Bh, 09Ch, 091h
      db 00Ah, 007h, 010h, 01Dh, 03Eh, 033h, 024h, 029h, 062h, 06Fh, 078h, 075h, 056h, 05Bh, 04Ch, 041h
      db 061h, 06Ch, 07Bh, 076h, 055h, 058h, 04Fh, 042h, 009h, 004h, 013h, 01Eh, 03Dh, 030h, 027h, 02Ah
      db 0B1h, 0BCh, 0ABh, 0A6h, 085h, 088h, 09Fh, 092h, 0D9h, 0D4h, 0C3h, 0CEh, 0EDh, 0E0h, 0F7h, 0FAh
      db 0B7h, 0BAh, 0ADh, 0A0h, 083h, 08Eh, 099h, 094h, 0DFh, 0D2h, 0C5h, 0C8h, 0EBh, 0E6h, 0F1h, 0FCh
      db 067h, 06Ah, 07Dh, 070h, 053h, 05Eh, 049h, 044h, 00Fh, 002h, 015h, 018h, 03Bh, 036h, 021h, 02Ch
      db 00Ch, 001h, 016h, 01Bh, 038h, 035h, 022h, 02Fh, 064h, 069h, 07Eh, 073h, 050h, 05Dh, 04Ah, 047h
      db 0DCh, 0D1h, 0C6h, 0CBh, 0E8h, 0E5h, 0F2h, 0FFh, 0B4h, 0B9h, 0AEh, 0A3h, 080h, 08Dh, 09Ah, 097h

_402310h:
      db 063h, 07Ch, 077h, 07Bh, 0F2h, 06Bh, 06Fh, 0C5h, 030h, 001h, 067h, 02Bh, 0FEh, 0D7h, 0ABh, 076h
      db 0CAh, 082h, 0C9h, 07Dh, 0FAh, 059h, 047h, 0F0h, 0ADh, 0D4h, 0A2h, 0AFh, 09Ch, 0A4h, 072h, 0C0h
      db 0B7h, 0FDh, 093h, 026h, 036h, 03Fh, 0F7h, 0CCh, 034h, 0A5h, 0E5h, 0F1h, 071h, 0D8h, 031h, 015h
      db 004h, 0C7h, 023h, 0C3h, 018h, 096h, 005h, 09Ah, 007h, 012h, 080h, 0E2h, 0EBh, 027h, 0B2h, 075h
      db 009h, 083h, 02Ch, 01Ah, 01Bh, 06Eh, 05Ah, 0A0h, 052h, 03Bh, 0D6h, 0B3h, 029h, 0E3h, 02Fh, 084h
      db 053h, 0D1h, 000h, 0EDh, 020h, 0FCh, 0B1h, 05Bh, 06Ah, 0CBh, 0BEh, 039h, 04Ah, 04Ch, 058h, 0CFh
      db 0D0h, 0EFh, 0AAh, 0FBh, 043h, 04Dh, 033h, 085h, 045h, 0F9h, 002h, 07Fh, 050h, 03Ch, 09Fh, 0A8h
      db 051h, 0A3h, 040h, 08Fh, 092h, 09Dh, 038h, 0F5h, 0BCh, 0B6h, 0DAh, 021h, 010h, 0FFh, 0F3h, 0D2h
      db 0CDh, 00Ch, 013h, 0ECh, 05Fh, 097h, 044h, 017h, 0C4h, 0A7h, 07Eh, 03Dh, 064h, 05Dh, 019h, 073h
      db 060h, 081h, 04Fh, 0DCh, 022h, 02Ah, 090h, 088h, 046h, 0EEh, 0B8h, 014h, 0DEh, 05Eh, 00Bh, 0DBh
      db 0E0h, 032h, 03Ah, 00Ah, 049h, 006h, 024h, 05Ch, 0C2h, 0D3h, 0ACh, 062h, 091h, 095h, 0E4h, 079h
      db 0E7h, 0C8h, 037h, 06Dh, 08Dh, 0D5h, 04Eh, 0A9h, 06Ch, 056h, 0F4h, 0EAh, 065h, 07Ah, 0AEh, 008h
      db 0BAh, 078h, 025h, 02Eh, 01Ch, 0A6h, 0B4h, 0C6h, 0E8h, 0DDh, 074h, 01Fh, 04Bh, 0BDh, 08Bh, 08Ah
      db 070h, 03Eh, 0B5h, 066h, 048h, 003h, 0F6h, 00Eh, 061h, 035h, 057h, 0B9h, 086h, 0C1h, 01Dh, 09Eh
      db 0E1h, 0F8h, 098h, 011h, 069h, 0D9h, 08Eh, 094h, 09Bh, 01Eh, 087h, 0E9h, 0CEh, 055h, 028h, 0DFh
      db 08Ch, 0A1h, 089h, 00Dh, 0BFh, 0E6h, 042h, 068h, 041h, 099h, 02Dh, 00Fh, 0B0h, 054h, 0BBh, 016h

_402410h:
      db 052h, 009h, 06Ah, 0D5h, 030h, 036h, 0A5h, 038h, 0BFh, 040h, 0A3h, 09Eh, 081h, 0F3h, 0D7h, 0FBh
      db 07Ch, 0E3h, 039h, 082h, 09Bh, 02Fh, 0FFh, 087h, 034h, 08Eh, 043h, 044h, 0C4h, 0DEh, 0E9h, 0CBh
      db 054h, 07Bh, 094h, 032h, 0A6h, 0C2h, 023h, 03Dh, 0EEh, 04Ch, 095h, 00Bh, 042h, 0FAh, 0C3h, 04Eh
      db 008h, 02Eh, 0A1h, 066h, 028h, 0D9h, 024h, 0B2h, 076h, 05Bh, 0A2h, 049h, 06Dh, 08Bh, 0D1h, 025h
      db 072h, 0F8h, 0F6h, 064h, 086h, 068h, 098h, 016h, 0D4h, 0A4h, 05Ch, 0CCh, 05Dh, 065h, 0B6h, 092h
      db 06Ch, 070h, 048h, 050h, 0FDh, 0EDh, 0B9h, 0DAh, 05Eh, 015h, 046h, 057h, 0A7h, 08Dh, 09Dh, 084h
      db 090h, 0D8h, 0ABh, 000h, 08Ch, 0BCh, 0D3h, 00Ah, 0F7h, 0E4h, 058h, 005h, 0B8h, 0B3h, 045h, 006h
      db 0D0h, 02Ch, 01Eh, 08Fh, 0CAh, 03Fh, 00Fh, 002h, 0C1h, 0AFh, 0BDh, 003h, 001h, 013h, 08Ah, 06Bh
      db 03Ah, 091h, 011h, 041h, 04Fh, 067h, 0DCh, 0EAh, 097h, 0F2h, 0CFh, 0CEh, 0F0h, 0B4h, 0E6h, 073h
      db 096h, 0ACh, 074h, 022h, 0E7h, 0ADh, 035h, 085h, 0E2h, 0F9h, 037h, 0E8h, 01Ch, 075h, 0DFh, 06Eh
      db 047h, 0F1h, 01Ah, 071h, 01Dh, 029h, 0C5h, 089h, 06Fh, 0B7h, 062h, 00Eh, 0AAh, 018h, 0BEh, 01Bh
      db 0FCh, 056h, 03Eh, 04Bh, 0C6h, 0D2h, 079h, 020h, 09Ah, 0DBh, 0C0h, 0FEh, 078h, 0CDh, 05Ah, 0F4h
      db 01Fh, 0DDh, 0A8h, 033h, 088h, 007h, 0C7h, 031h, 0B1h, 012h, 010h, 059h, 027h, 080h, 0ECh, 05Fh
      db 060h, 051h, 07Fh, 0A9h, 019h, 0B5h, 04Ah, 00Dh, 02Dh, 0E5h, 07Ah, 09Fh, 093h, 0C9h, 09Ch, 0EFh
      db 0A0h, 0E0h, 03Bh, 04Dh, 0AEh, 02Ah, 0F5h, 0B0h, 0C8h, 0EBh, 0BBh, 03Ch, 083h, 053h, 099h, 061h
      db 017h, 02Bh, 004h, 07Eh, 0BAh, 077h, 0D6h, 026h, 0E1h, 069h, 014h, 063h, 055h, 021h, 00Ch, 07Dh

_402510h:
      db 0A5h, 084h, 099h, 08Dh, 00Dh, 0BDh, 0B1h, 054h, 050h, 003h, 0A9h, 07Dh, 019h, 062h, 0E6h, 09Ah
      db 045h, 09Dh, 040h, 087h, 015h, 0EBh, 0C9h, 00Bh, 0ECh, 067h, 0FDh, 0EAh, 0BFh, 0F7h, 096h, 05Bh
      db 0C2h, 01Ch, 0AEh, 06Ah, 05Ah, 041h, 002h, 04Fh, 05Ch, 0F4h, 034h, 008h, 093h, 073h, 053h, 03Fh
      db 00Ch, 052h, 065h, 05Eh, 028h, 0A1h, 00Fh, 0B5h, 009h, 036h, 09Bh, 03Dh, 026h, 069h, 0CDh, 09Fh
      db 01Bh, 09Eh, 074h, 02Eh, 02Dh, 0B2h, 0EEh, 0FBh, 0F6h, 04Dh, 061h, 0CEh, 07Bh, 03Eh, 071h, 097h
      db 0F5h, 068h, 000h, 02Ch, 060h, 01Fh, 0C8h, 0EDh, 0BEh, 046h, 0D9h, 04Bh, 0DEh, 0D4h, 0E8h, 04Ah
      db 06Bh, 02Ah, 0E5h, 016h, 0C5h, 0D7h, 055h, 094h, 0CFh, 010h, 006h, 081h, 0F0h, 044h, 0BAh, 0E3h
      db 0F3h, 0FEh, 0C0h, 08Ah, 0ADh, 0BCh, 048h, 004h, 0DFh, 0C1h, 075h, 063h, 030h, 01Ah, 00Eh, 06Dh
      db 04Ch, 014h, 035h, 02Fh, 0E1h, 0A2h, 0CCh, 039h, 057h, 0F2h, 082h, 047h, 0ACh, 0E7h, 02Bh, 095h
      db 0A0h, 098h, 0D1h, 07Fh, 066h, 07Eh, 0ABh, 083h, 0CAh, 029h, 0D3h, 03Ch, 079h, 0E2h, 01Dh, 076h
      db 03Bh, 056h, 04Eh, 01Eh, 0DBh, 00Ah, 06Ch, 0E4h, 05Dh, 06Eh, 0EFh, 0A6h, 0A8h, 0A4h, 037h, 08Bh
      db 032h, 043h, 059h, 0B7h, 08Ch, 064h, 0D2h, 0E0h, 0B4h, 0FAh, 007h, 025h, 0AFh, 08Eh, 0E9h, 018h
      db 0D5h, 088h, 06Fh, 072h, 024h, 0F1h, 0C7h, 051h, 023h, 07Ch, 09Ch, 021h, 0DDh, 0DCh, 086h, 085h
      db 090h, 042h, 0C4h, 0AAh, 0D8h, 005h, 001h, 012h, 0A3h, 05Fh, 0F9h, 0D0h, 091h, 058h, 027h, 0B9h
      db 038h, 013h, 0B3h, 033h, 0BBh, 070h, 089h, 0A7h, 0B6h, 022h, 092h, 020h, 049h, 0FFh, 078h, 07Ah
      db 08Fh, 0F8h, 080h, 017h, 0DAh, 031h, 0C6h, 0B8h, 0C3h, 0B0h, 077h, 011h, 0CBh, 0FCh, 0D6h, 03Ah

_402610h:
      db 0C6h, 0F8h, 0EEh, 0F6h, 0FFh, 0D6h, 0DEh, 091h, 060h, 002h, 0CEh, 056h, 0E7h, 0B5h, 04Dh, 0ECh
      db 08Fh, 01Fh, 089h, 0FAh, 0EFh, 0B2h, 08Eh, 0FBh, 041h, 0B3h, 05Fh, 045h, 023h, 053h, 0E4h, 09Bh
      db 075h, 0E1h, 03Dh, 04Ch, 06Ch, 07Eh, 0F5h, 083h, 068h, 051h, 0D1h, 0F9h, 0E2h, 0ABh, 062h, 02Ah
      db 008h, 095h, 046h, 09Dh, 030h, 037h, 00Ah, 02Fh, 00Eh, 024h, 01Bh, 0DFh, 0CDh, 04Eh, 07Fh, 0EAh
      db 012h, 01Dh, 058h, 034h, 036h, 0DCh, 0B4h, 05Bh, 0A4h, 076h, 0B7h, 07Dh, 052h, 0DDh, 05Eh, 013h
      db 0A6h, 0B9h, 000h, 0C1h, 040h, 0E3h, 079h, 0B6h, 0D4h, 08Dh, 067h, 072h, 094h, 098h, 0B0h, 085h
      db 0BBh, 0C5h, 04Fh, 0EDh, 086h, 09Ah, 066h, 011h, 08Ah, 0E9h, 004h, 0FEh, 0A0h, 078h, 025h, 04Bh
      db 0A2h, 05Dh, 080h, 005h, 03Fh, 021h, 070h, 0F1h, 063h, 077h, 0AFh, 042h, 020h, 0E5h, 0FDh, 0BFh
      db 081h, 018h, 026h, 0C3h, 0BEh, 035h, 088h, 02Eh, 093h, 055h, 0FCh, 07Ah, 0C8h, 0BAh, 032h, 0E6h
      db 0C0h, 019h, 09Eh, 0A3h, 044h, 054h, 03Bh, 00Bh, 08Ch, 0C7h, 06Bh, 028h, 0A7h, 0BCh, 016h, 0ADh
      db 0DBh, 064h, 074h, 014h, 092h, 00Ch, 048h, 0B8h, 09Fh, 0BDh, 043h, 0C4h, 039h, 031h, 0D3h, 0F2h
      db 0D5h, 08Bh, 06Eh, 0DAh, 001h, 0B1h, 09Ch, 049h, 0D8h, 0ACh, 0F3h, 0CFh, 0CAh, 0F4h, 047h, 010h
      db 06Fh, 0F0h, 04Ah, 05Ch, 038h, 057h, 073h, 097h, 0CBh, 0A1h, 0E8h, 03Eh, 096h, 061h, 00Dh, 00Fh
      db 0E0h, 07Ch, 071h, 0CCh, 090h, 006h, 0F7h, 01Ch, 0C2h, 06Ah, 0AEh, 069h, 017h, 099h, 03Ah, 027h
      db 0D9h, 0EBh, 02Bh, 022h, 0D2h, 0A9h, 007h, 033h, 02Dh, 03Ch, 015h, 0C9h, 087h, 0AAh, 050h, 0A5h
      db 003h, 059h, 009h, 01Ah, 065h, 0D7h, 084h, 0D0h, 082h, 029h, 05Ah, 01Eh, 07Bh, 0A8h, 06Dh, 02Ch

_402710h:
      db 000h, 00Bh, 016h, 01Dh, 02Ch, 027h, 03Ah, 031h, 058h, 053h, 04Eh, 045h, 074h, 07Fh, 062h, 069h
      db 0B0h, 0BBh, 0A6h, 0ADh, 09Ch, 097h, 08Ah, 081h, 0E8h, 0E3h, 0FEh, 0F5h, 0C4h, 0CFh, 0D2h, 0D9h
      db 07Bh, 070h, 06Dh, 066h, 057h, 05Ch, 041h, 04Ah, 023h, 028h, 035h, 03Eh, 00Fh, 004h, 019h, 012h
      db 0CBh, 0C0h, 0DDh, 0D6h, 0E7h, 0ECh, 0F1h, 0FAh, 093h, 098h, 085h, 08Eh, 0BFh, 0B4h, 0A9h, 0A2h
      db 0F6h, 0FDh, 0E0h, 0EBh, 0DAh, 0D1h, 0CCh, 0C7h, 0AEh, 0A5h, 0B8h, 0B3h, 082h, 089h, 094h, 09Fh
      db 046h, 04Dh, 050h, 05Bh, 06Ah, 061h, 07Ch, 077h, 01Eh, 015h, 008h, 003h, 032h, 039h, 024h, 02Fh
      db 08Dh, 086h, 09Bh, 090h, 0A1h, 0AAh, 0B7h, 0BCh, 0D5h, 0DEh, 0C3h, 0C8h, 0F9h, 0F2h, 0EFh, 0E4h
      db 03Dh, 036h, 02Bh, 020h, 011h, 01Ah, 007h, 00Ch, 065h, 06Eh, 073h, 078h, 049h, 042h, 05Fh, 054h
      db 0F7h, 0FCh, 0E1h, 0EAh, 0DBh, 0D0h, 0CDh, 0C6h, 0AFh, 0A4h, 0B9h, 0B2h, 083h, 088h, 095h, 09Eh
      db 047h, 04Ch, 051h, 05Ah, 06Bh, 060h, 07Dh, 076h, 01Fh, 014h, 009h, 002h, 033h, 038h, 025h, 02Eh
      db 08Ch, 087h, 09Ah, 091h, 0A0h, 0ABh, 0B6h, 0BDh, 0D4h, 0DFh, 0C2h, 0C9h, 0F8h, 0F3h, 0EEh, 0E5h
      db 03Ch, 037h, 02Ah, 021h, 010h, 01Bh, 006h, 00Dh, 064h, 06Fh, 072h, 079h, 048h, 043h, 05Eh, 055h
      db 001h, 00Ah, 017h, 01Ch, 02Dh, 026h, 03Bh, 030h, 059h, 052h, 04Fh, 044h, 075h, 07Eh, 063h, 068h
      db 0B1h, 0BAh, 0A7h, 0ACh, 09Dh, 096h, 08Bh, 080h, 0E9h, 0E2h, 0FFh, 0F4h, 0C5h, 0CEh, 0D3h, 0D8h
      db 07Ah, 071h, 06Ch, 067h, 056h, 05Dh, 040h, 04Bh, 022h, 029h, 034h, 03Fh, 00Eh, 005h, 018h, 013h
      db 0CAh, 0C1h, 0DCh, 0D7h, 0E6h, 0EDh, 0F0h, 0FBh, 092h, 099h, 084h, 08Fh, 0BEh, 0B5h, 0A8h, 0A3h
Подякували: 0xDADA11C7, Pernat1y2

3

Re: [FASM] aes256 (cbc, with/without tables)

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',\
            memcpy, 'memcpy',\
            memcmp, 'memcmp'

import      advapi32,\
            RtlGenRandom, 'SystemFunction036'


;   -----------------------------------
    include ''

    struct aes_context
        ksch    rb 240
        rnd     rb 1
    ends
;   -----------------------------------

    SZ = 5 * 16

proc print, lab, buf, sz
    locals
        frmt_byte db '%02X ', 0
        frmt_text db '%s: ', 0
    endl

    cinvoke printf, addr frmt_text, [lab]

    mov esi, [buf]
    xor ecx, ecx

@@: push ecx

    and ecx, 0xF
    jne .next
    cinvoke printf, next_line

.next:
    movzx eax, byte[esi]
    cinvoke printf, addr frmt_byte, eax

    pop ecx
    inc ecx
    inc esi

    cmp ecx, [sz]
    jne @b

    cinvoke printf, two_next_line

    ret
endp

proc rnd, buf, sz_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, [sz_buf]
    jl @b

    ret
endp


entry $

;    xor ecx, ecx
;@@: push ecx

    stdcall rnd, input, SZ

    stdcall rnd, key, 32

    stdcall rnd, iv_enc, 16
    cinvoke memcpy, iv_dec, iv_enc, 16


    stdcall print, text_key, key, 32
    stdcall print, text_iv, iv_enc, 16
    stdcall print, text_input, input, SZ

    stdcall aes_set_key, key, 32, ctx

    stdcall aes256_cbc, input, dec_input, 5, iv_enc, ctx, AES_ENCRYPT

    stdcall print, text_dec_input, dec_input, SZ

    stdcall aes256_cbc, dec_input, dec_output, 5, iv_dec, ctx, AES_DECRYPT
    
    stdcall print, text_dec_output, dec_output, SZ

;    cinvoke memcmp, input, dec_output, SZ
;    cmp eax, 0
;    jne not_eq

;    cinvoke printf, equally
;    jmp fin

;not_eq:
;    cinvoke printf, not_equal
;    cinvoke getchar

;fin:
;    pop ecx
;    inc ecx
;    cmp ecx, 40
;    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
    finish                  db 13, 10, 'finish ok!', 13, 10, 0

    text_input              db 'input', 0
    input                   rb SZ

    text_key                db 'key', 0
    key                     rb 32

    text_iv                 db 'iv', 0
    iv_enc                  rb 16
    iv_dec                  rb 16

    text_dec_input          db 'dec_input', 0
    dec_input               rb SZ

    text_dec_output         db 'dec_output', 0
    dec_output              rb SZ

    ctx                     aes_context

    next_line               db 13, 10, 0
    two_next_line           db 13, 10, 13, 10, 0
Подякували: 0xDADA11C7, Pernat1y2

4

Re: [FASM] aes256 (cbc, with/without tables)

Чи суттєва різниця в швидкості роботи між табличною і без табличною реалізацією? Бо по розміру вони здається мають вийти однакові незважаючи на кількість строк коду.

5 Востаннє редагувалося Kane (08.08.2015 17:52:49)

Re: [FASM] aes256 (cbc, with/without tables)

Швидше з таблицями, але не економно по пам'яті. По цифрам не знаю, не заміряв.

6

Re: [FASM] aes256 (cbc, with/without tables)

Kane написав:

Швидше з таблицями, але не економно по пам'яті. По цифрам не знаю, не заміряв.

Ну немає цифр то немає.

7

Re: [FASM] aes256 (cbc, with/without tables)

Та всім пофіг) Практичної необхідності у цьому коді немає. Практичніше юзати оригінал (http://www.gladman.me.uk/), а не подібні милиці. Шкода, що я це тільки зараз зрозумів. Крутизни це не додає..

8

Re: [FASM] aes256 (cbc, with/without tables)

Ріп це вже цікаво, хтось по ньому може навіть компілер визначити

9 Востаннє редагувалося Kane (09.08.2015 15:58:16)

Re: [FASM] aes256 (cbc, with/without tables)

0xDADA11C7 написав:

Ріп це вже цікаво, хтось по ньому може навіть компілер визначити

Сенс, окрім статистики для аверів?

10

Re: [FASM] aes256 (cbc, with/without tables)

Сенс, окрім статистики для аверів?

Вас весь час турбує сенс, то може ви його втратили і шукаєте? Сенсів насправді багато, від розвитку форуму і навчання початківців до наочних прикладів машинного коду, що генерують сучасні компілери. От я знаю що вони генерують, а більш високорівневі кодери можуть думати, що розробники компілерів їдять веселку і серуть метеликами типова оптимізація вже ідеальна в будь-якому сучасному компілері.

11

Re: [FASM] aes256 (cbc, with/without tables)

0xDADA11C7 написав:

Сенс, окрім статистики для аверів?

Вас весь час турбує сенс, то може ви його втратили і шукаєте?

В IT так.