//
// tls_finish_handshake from 0x9bb46c to 0x9bb5bc (336 bytes)
//
// 3 xrefs:
// > ossl_statem_client_pre_work @ 0x9b5128
// > ossl_statem_server_pre_work @ 0x9bd0f4
// > ??> @ 0x769ec
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:07:01 +0000
//
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;
}