Function at 0x406580
Capabilities:
Encrypt data using rc4 ksa

Disassembly:
push ebp
mov ebp, esp
sub esp, 0x6c
mov eax, dword [0x541a34]
xor eax, ebp
mov dword [ebp - 4], eax
push ebx
push esi
push edi
push 0x528d00
push 0x628
push str.....library_ssl_tls.c
mov esi, ecx
mov dword [ebp - 0x50], 1
push 2
xor ebx, ebx
mov dword [ebp - 0x64], esi
push esi
mov dword [ebp - 0x5c], ebx
call fcn.00416cf0
mov eax, dword [esi + 0x2c]
add esp, 0x14
test eax, eax
je 0x406eba
mov ecx, dword [esi + 0x40]
test ecx, ecx
je 0x406eba
lea eax, [ecx + 0x90]
mov dword [ebp - 0x4c], eax
test eax, eax
je 0x4065ec
mov eax, dword [eax]
test eax, eax
je 0x4065ec
mov eax, dword [eax + 4]
jmp 0x4065ee
xor eax, eax
mov edx, dword [ecx + 8]
mov edi, dword [esi + 0x7c]
cmp edi, edx
jae 0x40662a
push edx
push edi
push str.in_msglen___d____minlen___d_
push 0x635
push str.....library_ssl_tls.c
push 1
push esi
call fcn.00416cf0
add esp, 0x1c
mov eax, 0xffff8e80
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004d1fac
mov esp, ebp
pop ebp
ret
cmp eax, 7
jne 0x4066a0
mov eax, dword [esi + 0x70]
lea edx, [ebp - 0x48]
push edx
push eax
push edi
push eax
push dword [ecx + 0xc]
lea edx, [ecx + 0x28]
mov dword [ebp - 0x48], ebx
mov ecx, dword [ebp - 0x4c]
xor ebx, ebx
call fcn.00417ef0
mov edi, eax
add esp, 0x14
test edi, edi
je 0x406685
push edi
push str.mbedtls_cipher_crypt
push 0x647
push str.....library_ssl_tls.c
lea edx, [ebx + 1]
mov ecx, esi
call fcn.00416d80
add esp, 0x10
mov eax, edi
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004d1fac
mov esp, ebp
pop ebp
ret
mov eax, dword [esi + 0x7c]
cmp eax, dword [ebp - 0x48]
je 0x406c2d
push str.should_never_happen
push 0x64d
jmp 0x406ec4
cmp eax, 6
je 0x406a71
cmp eax, 8
je 0x406a71
cmp eax, 2
jne 0x406a62
xor edx, edx
mov dword [ebp - 0x58], edx
cmp dword [esi + 0x14], eax
jl 0x4066c8
mov edx, dword [ecx + 0xc]
mov eax, dword [ecx + 0xc]
add eax, edx
cmp edi, eax
jb 0x406a4f
mov eax, dword [ecx + 0x14]
inc eax
add eax, edx
cmp edi, eax
jb 0x406a4f
mov eax, dword [esi + 0x70]
mov dword [ebp - 0x54], eax
mov eax, dword [esi + 0x2c]
mov dword [ebp - 0x48], edi
cmp dword [eax + 0x80], 1
jne 0x40685e
push str.using_encrypt_then_mac
push 0x6c9
push str.....library_ssl_tls.c
push 3
push esi
call fcn.00416cf0
mov eax, dword [esi + 0x40]
add esp, 0x14
mov ecx, dword [esi + 0x60]
mov edx, 4
mov eax, dword [eax + 0x14]
sub dword [ebp - 0x48], eax
sub dword [esi + 0x7c], eax
mov eax, dword [ecx]
mov dword [ebp - 0x14], eax
mov eax, dword [ecx + 4]
mov ecx, dword [esi + 0x64]
mov dword [ebp - 0x10], eax
push 0xd
mov ax, word [ecx]
mov word [ebp - 0xc], ax
movzx eax, byte [ecx + 2]
mov ecx, esi
mov byte [ebp - 0xa], al
movzx eax, byte [esi + 0x7d]
mov byte [ebp - 9], al
movzx eax, byte [esi + 0x7c]
mov byte [ebp - 8], al
lea eax, [ebp - 0x14]
push eax
push str.MACd_meta_data
push 0x6d3
push str.....library_ssl_tls.c
call fcn.00416e10
mov ecx, dword [esi + 0x40]
lea edx, [ebp - 0x14]
add esp, 0x14
add ecx, 0x44
push 0xd
call fcn.00410b90
mov ecx, dword [esi + 0x40]
add esp, 4
mov edx, dword [esi + 0x6c]
add ecx, 0x44
push dword [esi + 0x7c]
call fcn.00410b90
mov ecx, dword [esi + 0x40]
lea edx, [ebp - 0x44]
add esp, 4
add ecx, 0x44
call fcn.00410bc0
mov ecx, dword [esi + 0x40]
add ecx, 0x44
call fcn.00410c60
mov eax, dword [esi + 0x40]
mov edx, 4
mov ecx, esi
push dword [eax + 0x14]
mov eax, dword [esi + 0x7c]
add eax, dword [esi + 0x6c]
push eax
push str.message__mac
push 0x6dc
push str.....library_ssl_tls.c
call fcn.00416e10
mov eax, dword [esi + 0x40]
add esp, 0x14
mov edx, 4
mov ecx, esi
push dword [eax + 0x14]
lea eax, [ebp - 0x44]
push eax
push str.computed_mac
push 0x6de
push str.....library_ssl_tls.c
call fcn.00416e10
mov eax, dword [esi + 0x40]
add esp, 0x14
mov edi, dword [esi + 0x7c]
mov ecx, dword [esi + 0x6c]
push dword [eax + 0x14]
add ecx, edi
lea edx, [ebp - 0x44]
call fcn.00404510
add esp, 4
test eax, eax
je 0x406853
push str.message_mac_does_not_match
push 0x6e3
push str.....library_ssl_tls.c
push 1
push esi
call fcn.00416cf0
mov eax, 0xffff8e80
add esp, 0x14
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004d1fac
mov esp, ebp
pop ebp
ret
mov ecx, dword [esi + 0x40]
mov ebx, 1
mov dword [ebp - 0x5c], ebx
mov eax, dword [ecx + 0xc]
xor edx, edx
mov dword [ebp - 0x4c], eax
mov eax, edi
div dword [ecx + 0xc]
test edx, edx
je 0x406882
push dword [ebp - 0x4c]
push edi
push str.msglen___d_____ivlen___d____0
push 0x6f1
jmp 0x406604
cmp dword [esi + 0x14], 2
jl 0x4068b6
mov eax, dword [ecx + 0xc]
xor edx, edx
sub dword [ebp - 0x48], eax
sub edi, eax
mov dword [esi + 0x7c], edi
cmp dword [ecx + 0xc], edx
jbe 0x4068b6
nop word [eax + eax]
mov eax, dword [esi + 0x6c]
mov ecx, dword [esi + 0x40]
mov al, byte [edx + eax]
mov byte [edx + ecx + 0x28], al
inc edx
mov eax, dword [esi + 0x40]
cmp edx, dword [eax + 0xc]
jb 0x4068a0
mov ecx, dword [esi + 0x40]
lea eax, [ebp - 0x58]
mov edi, dword [ebp - 0x48]
push eax
mov eax, dword [ebp - 0x54]
push eax
push edi
push eax
push dword [ecx + 0xc]
lea edx, [ecx + 0x28]
add ecx, 0x90
call fcn.00417ef0
add esp, 0x14
mov dword [ebp - 0x4c], eax
test eax, eax
je 0x406914
push eax
push str.mbedtls_cipher_crypt
push 0x709
push str.....library_ssl_tls.c
mov edx, 1
mov ecx, esi
call fcn.00416d80
mov eax, dword [ebp - 0x4c]
add esp, 0x10
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004d1fac
mov esp, ebp
pop ebp
ret
cmp edi, dword [ebp - 0x58]
je 0x406928
push str.should_never_happen
push 0x70f
jmp 0x406ec4
cmp dword [esi + 0x14], 2
jge 0x406947
mov ecx, dword [esi + 0x40]
push dword [ecx + 0xc]
lea eax, [ecx + 0xb8]
push eax
lea eax, [ecx + 0x28]
push eax
call fcn.004d5f40
add esp, 0xc
mov ecx, dword [esi + 0x7c]
mov eax, dword [esi + 0x70]
mov dword [ebp - 0x60], eax
mov dword [ebp - 0x4c], ecx
movzx edi, byte [eax + ecx - 1]
mov eax, dword [esi + 0x40]
inc edi
mov dword [ebp - 0x48], edi
mov eax, dword [eax + 0x14]
mov dword [ebp - 0x54], eax
add eax, edi
cmp ecx, eax
jae 0x406977
test ebx, ebx
jne 0x406977
xor edi, edi
mov dword [ebp - 0x48], edi
mov dword [ebp - 0x50], edi
cmp dword [esi + 0x14], 0
jle 0x406a40
mov eax, dword [ebp - 0x54]
mov edx, ecx
sub edx, edi
add eax, 0x4000
dec edx
xor esi, esi
cmp edx, eax
mov dword [ebp - 0x68], esi
lea eax, [edi + 1]
sbb ecx, ecx
neg ecx
lea ebx, [esi + 1]
cmp dword [ebp - 0x4c], eax
mov edi, ebx
sbb eax, eax
inc eax
and ecx, eax
mov eax, dword [ebp - 0x50]
and eax, ecx
mov ecx, dword [ebp - 0x60]
imul edx, eax
inc ecx
mov dword [ebp - 0x50], eax
mov eax, dword [ebp - 0x48]
dec eax
mov dword [ebp - 0x58], eax
add ecx, edx
mov edx, dword [ebp - 0x48]
mov dword [ebp - 0x54], ecx
cmp edx, edi
sbb eax, eax
inc eax
and ebx, eax
movzx eax, byte [ecx + edi - 1]
xor ecx, ecx
cmp eax, dword [ebp - 0x58]
lea eax, [edi + 1]
sete cl
imul ecx, ebx
add esi, ecx
cmp edx, eax
sbb eax, eax
xor ecx, ecx
inc eax
and ebx, eax
mov eax, dword [ebp - 0x54]
movzx eax, byte [eax + edi]
cmp eax, dword [ebp - 0x58]
mov eax, dword [ebp - 0x68]
sete cl
add edi, 2
imul ecx, ebx
add eax, ecx
mov ecx, dword [ebp - 0x54]
mov dword [ebp - 0x68], eax
cmp edi, 0x100
jbe 0x4069c7
mov ecx, dword [ebp - 0x50]
add esi, eax
xor eax, eax
cmp esi, edx
mov esi, dword [ebp - 0x64]
sete al
and ecx, eax
imul eax, ecx, 0x1ff
mov dword [ebp - 0x50], ecx
and edx, eax
mov eax, dword [ebp - 0x4c]
sub eax, edx
mov dword [ebp - 0x48], edx
mov dword [esi + 0x7c], eax
mov ebx, edx
jmp 0x406c2d
push str.should_never_happen
push 0x769
jmp 0x406ec4
push dword [ecx + 0x14]
push dword [ecx + 0xc]
push edi
push str.msglen___d____max__ivlen__d___maclen___d___1______expl_IV__
push 0x6b8
jmp 0x406aa1
push str.should_never_happen
push 0x773
jmp 0x406ec4
mov eax, dword [ecx]
mov edx, dword [ecx + 0xc]
test byte [eax + 0x24], 2
sete al
sub edx, dword [ecx + 0x10]
lea eax, [eax*8 + 8]
movzx ecx, al
mov dword [ebp - 0x4c], ecx
lea eax, [ecx + edx]
cmp edi, eax
jae 0x406ac7
push ecx
push edx
push edi
push str.msglen___d____explicit_iv_len___d___taglen___d_
push 0x665
push str.....library_ssl_tls.c
push 1
push esi
call fcn.00416cf0
add esp, 0x20
mov eax, 0xffff8e80
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004d1fac
mov esp, ebp
pop ebp
ret
mov ebx, dword [esi + 0x70]
sub edi, ecx
mov ecx, dword [esi + 0x60]
sub edi, edx
mov edx, dword [esi + 0x14]
mov dword [esi + 0x7c], edi
mov dword [ebp - 0x64], edi
mov eax, dword [ecx]
mov dword [ebp - 0x14], eax
mov eax, dword [ecx + 4]
mov ecx, dword [esi + 0x10]
mov dword [ebp - 0x10], eax
movzx eax, byte [esi + 0x78]
mov byte [ebp - 0xc], al
lea eax, [ebp - 0xb]
push eax
mov eax, dword [esi]
mov eax, dword [eax + 0xcc]
shr eax, 1
and eax, 1
push eax
call fcn.0040c390
movzx eax, byte [esi + 0x7d]
mov edx, 4
mov byte [ebp - 9], al
mov ecx, esi
movzx eax, byte [esi + 0x7c]
push 0xd
mov byte [ebp - 8], al
lea eax, [ebp - 0x14]
push eax
push str.additional_data_used_for_AEAD
push 0x676
push str.....library_ssl_tls.c
call fcn.00416e10
mov edx, dword [esi + 0x40]
add esp, 0x1c
mov eax, dword [edx + 0xc]
sub eax, dword [edx + 0x10]
push eax
push dword [esi + 0x6c]
lea eax, [edx + 0x28]
add eax, dword [edx + 0x10]
push eax
call fcn.004d5f40
mov eax, dword [esi + 0x40]
add esp, 0xc
mov edx, 4
mov ecx, esi
push dword [eax + 0xc]
add eax, 0x28
push eax
push str.IV_used
push 0x67d
push str.....library_ssl_tls.c
call fcn.00416e10
add esp, 0x14
add edi, ebx
mov edx, 4
mov ecx, esi
push dword [ebp - 0x4c]
push edi
push str.TAG_used
push 0x67e
push str.....library_ssl_tls.c
call fcn.00416e10
mov ecx, dword [esi + 0x40]
lea eax, [ebp - 0x60]
add esp, 0x14
lea edx, [ecx + 0x28]
push dword [ebp - 0x4c]
push edi
mov edi, dword [ebp - 0x64]
push eax
push ebx
push edi
push ebx
push ecx
lea eax, [ebp - 0x14]
push eax
push dword [ecx + 0xc]
add ecx, 0x90
call fcn.00418050
mov ebx, eax
add esp, 0x24
test ebx, ebx
je 0x406c10
push ebx
push str.mbedtls_cipher_auth_decrypt
push 0x68b
push str.....library_ssl_tls.c
mov edx, 1
mov ecx, esi
call fcn.00416d80
add esp, 0x10
mov eax, 0xffff8e80
cmp ebx, 0xffff9d00
cmove ebx, eax
mov eax, ebx
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004d1fac
mov esp, ebp
pop ebp
ret
mov dword [ebp - 0x5c], 1
cmp dword [ebp - 0x60], edi
je 0x406c2b
push str.should_never_happen
push 0x696
jmp 0x406ec4
xor ebx, ebx
push dword [esi + 0x7c]
mov edx, 4
mov ecx, esi
push dword [esi + 0x70]
push str.raw_buffer_after_decryption
push 0x778
push str.....library_ssl_tls.c
call fcn.00416e10
mov eax, dword [ebp - 0x5c]
add esp, 0x14
test eax, eax
jne 0x406df9
mov eax, dword [esi + 0x40]
mov eax, dword [eax + 0x14]
sub dword [esi + 0x7c], eax
mov eax, dword [esi + 0x68]
mov ecx, dword [esi + 0x7c]
shr ecx, 8
mov byte [eax], cl
mov ecx, dword [esi + 0x68]
mov al, byte [esi + 0x7c]
mov byte [ecx + 1], al
mov eax, dword [esi + 0x40]
mov edi, dword [esi + 0x7c]
push dword [eax + 0x14]
mov eax, dword [esi + 0x70]
add eax, edi
push eax
lea eax, [ebp - 0x44]
push eax
call fcn.004d5f40
add esp, 0xc
cmp dword [esi + 0x14], 0
jle 0x406dea
mov eax, dword [esi + 0x7c]
add ebx, 0x15
mov ecx, dword [esi + 0x40]
add edi, ebx
mov ebx, dword [ebp - 0x50]
add eax, 0x15
mov edx, dword [esi + 0x60]
add ecx, 0x44
shr eax, 6
shr edi, 6
sub edi, eax
imul eax, ebx, 0xff
push 8
and edi, eax
call fcn.00410b90
mov ecx, dword [esi + 0x40]
add esp, 4
mov edx, dword [esi + 0x64]
add ecx, 0x44
push 3
call fcn.00410b90
mov ecx, dword [esi + 0x40]
add esp, 4
mov edx, dword [esi + 0x68]
add ecx, 0x44
push 2
call fcn.00410b90
mov ecx, dword [esi + 0x40]
add esp, 4
mov edx, dword [esi + 0x70]
add ecx, 0x44
push dword [esi + 0x7c]
call fcn.00410b90
mov edx, dword [esi + 0x7c]
add esp, 4
mov ecx, dword [esi + 0x40]
add edx, dword [esi + 0x70]
add ecx, 0x44
call fcn.00410bc0
add edi, 1
je 0x406d41
nop
mov eax, dword [esi + 0x40]
add eax, 0x44
je 0x406d3c
mov ecx, dword [eax]
test ecx, ecx
je 0x406d3c
push dword [esi + 0x70]
push dword [eax + 4]
mov eax, dword [ecx + 0x2c]
call eax
add esp, 8
sub edi, 1
jne 0x406d20
mov ecx, dword [esi + 0x40]
add ecx, 0x44
call fcn.00410c60
mov eax, dword [esi + 0x40]
mov edx, 4
mov ecx, esi
push dword [eax + 0x14]
lea eax, [ebp - 0x44]
push eax
push str.message__mac
push 0x7c0
push str.....library_ssl_tls.c
call fcn.00416e10
mov eax, dword [esi + 0x40]
add esp, 0x14
mov edx, 4
mov ecx, esi
push dword [eax + 0x14]
mov eax, dword [esi + 0x7c]
add eax, dword [esi + 0x70]
push eax
push str.computed_mac
push 0x7c2
push str.....library_ssl_tls.c
call fcn.00416e10
mov eax, dword [esi + 0x40]
lea ecx, [ebp - 0x44]
mov edx, dword [esi + 0x7c]
add esp, 0x14
add edx, dword [esi + 0x70]
push dword [eax + 0x14]
call fcn.00404510
add esp, 4
test eax, eax
jne 0x406614
test ebx, ebx
je 0x406614
cmp dword [esi + 0x7c], 0
jne 0x406e0d
inc dword [esi + 0xa4]
cmp dword [esi + 0xa4], 3
jle 0x406e17
push str.received_four_consecutive_empty_messages__possible_DoS_attack
push 0x7e8
jmp 0x40682d
push str.should_never_happen
push 0x7bc
jmp 0x406ec4
cmp eax, 1
je 0x406dc6
push str.should_never_happen
push 0x7d9
jmp 0x406ec4
mov dword [esi + 0xa4], 0
mov eax, dword [esi]
test byte [eax + 0xcc], 2
jne 0x406e8d
mov ecx, 8
nop word [eax + eax]
mov eax, dword [esi]
movzx eax, byte [eax + 0xcc]
and eax, 2
cmp ecx, eax
jbe 0x406e4d
mov eax, dword [esi + 0x60]
add byte [eax + ecx - 1], 1
jne 0x406e4d
dec ecx
jmp 0x406e30
mov eax, dword [esi]
movzx eax, byte [eax + 0xcc]
and eax, 2
cmp ecx, eax
jne 0x406e8d
push str.incoming_message_counter_would_wrap
push 0x7fe
push str.....library_ssl_tls.c
push 1
push esi
call fcn.00416cf0
mov eax, 0xffff9480
add esp, 0x14
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004d1fac
mov esp, ebp
pop ebp
ret
push str.__decrypt_buf
push 0x803
push str.....library_ssl_tls.c
push 2
push esi
call fcn.00416cf0
add esp, 0x14
xor eax, eax
pop edi
pop esi
pop ebx
mov ecx, dword [ebp - 4]
xor ecx, ebp
call fcn.004d1fac
mov esp, ebp
pop ebp
ret
push str.should_never_happen
push 0x62c
push str.....library_ssl_tls.c
push 1
push esi
call fcn.00416cf0
mov ecx, dword [ebp - 4]
add esp, 0x14
xor ecx, ebp
mov eax, 0xffff9400
pop edi
pop esi
pop ebx
call fcn.004d1fac
mov esp, ebp
pop ebp
ret