//
// tls_finish_handshake from 0x7a6868 to 0x7a69b8 (336 bytes)
//
// 3 xrefs:
// > ossl_statem_client_pre_work @ 0x7a0524
// > ossl_statem_server_pre_work @ 0x7a84f0
// > ??> @ 0x5cf6c
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall tls_finish_handshake(_DWORD *a1)
{
int v2; // r3
_DWORD *v4; // r3
void (__fastcall *v5)(_DWORD *, int, int); // r12
int v6; // r2
_WORD *v7; // r3
_WORD *v8; // r1
ssl3_cleanup_key_block();
if ( (*(_DWORD *)(*(_DWORD *)(a1[1] + 100) + 52) & 8) == 0 )
{
BUF_MEM_free(a1[22]);
a1[22] = 0;
}
ssl_free_wbio_buffer((int)a1);
v2 = a1[7];
a1[24] = 0;
if ( v2 )
{
if ( a1[121] != 2 )
return 1;
a1[121] = 0;
a1[8] = 0;
ssl_update_cache(a1, 2);
v4 = (_DWORD *)a1[69];
v5 = (void (__fastcall *)(_DWORD *, int, int))a1[64];
++v4[18];
a1[6] = ossl_statem_accept;
if ( v5 )
goto LABEL_9;
}
else
{
a1[121] = 0;
a1[8] = 0;
ssl_update_cache(a1, 1);
v4 = (_DWORD *)a1[69];
if ( a1[30] )
++v4[22];
v5 = (void (__fastcall *)(_DWORD *, int, int))a1[64];
v6 = v4[15] + 1;
a1[6] = ossl_statem_connect;
v4[15] = v6;
if ( v5 )
goto LABEL_9;
}
v5 = (void (__fastcall *)(_DWORD *, int, int))v4[37];
if ( v5 )
LABEL_9:
v5(a1, 32, 1);
if ( (*(_DWORD *)(*(_DWORD *)(a1[1] + 100) + 52) & 8) == 0 )
return 1;
v7 = (_WORD *)a1[27];
v8 = v7 + 134;
v7 += 132;
*v8 = 0;
*v7 = 0;
v7[1] = 0;
dtls1_clear_received_buffer(a1);
return 1;
}