//
// ssl_cipher_get_evp from 0x9a88f8 to 0x9a8ce4 (1004 bytes)
//
// 3 xrefs:
// > ssl3_setup_key_block @ 0x9cd0a0
// > tls1_setup_key_block @ 0x9cf51c
// > ??> @ 0x7504c
//
// 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:06:52 +0000
//
int __fastcall ssl_cipher_get_evp(int *a1, int *a2, int *a3, _DWORD *a4, _DWORD *a5, _DWORD *a6, int a7)
{
int v7; // r4
int v12; // r0
int v13; // r3
bool v14; // zf
int v15; // r1
_BOOL4 v16; // r12
_BOOL4 v17; // lr
int v18; // r12
int v19; // r3
int v20; // r0
_BOOL4 v21; // r3
int v22; // r3
int v23; // r3
int cipherbyname; // r0
int v26; // r3
int v27; // r0
int v28; // r2
int v29; // r3
int v30; // r3
int v31; // r0
int v32[4]; // [sp+4h] [bp-10h] BYREF
v7 = a1[43];
if ( !v7 )
return 0;
if ( a6 )
{
CRYPTO_THREAD_run_once(&unk_D34038, sub_9A757C);
v12 = dword_D33F70[0];
v13 = a1[42];
v14 = dword_D33F70[0] == 0;
*a6 = 0;
v32[0] = v13;
if ( !v14 )
{
v15 = OPENSSL_sk_find(v12, v32);
if ( v15 >= 0 )
*a6 = OPENSSL_sk_value(dword_D33F70[0], v15);
else
*a6 = 0;
}
v16 = a2 == nullptr;
v17 = a3 == nullptr;
if ( !v16 || !v17 )
{
v18 = v17 || v16;
if ( !v18 )
goto LABEL_9;
return 0;
}
return 1;
}
v18 = a3 == nullptr || a2 == nullptr;
if ( v18 )
return 0;
LABEL_9:
while ( *(_DWORD *)(v7 + 20) != dword_C51598[2 * v18] )
{
if ( ++v18 == 20 )
{
*a2 = 0;
goto LABEL_12;
}
}
if ( v18 == 5 )
*a2 = EVP_enc_null();
else
*a2 = dword_D33F70[v18 + 3];
LABEL_12:
v19 = *(_DWORD *)(v7 + 24);
switch ( v19 )
{
case 1:
v27 = 0;
goto LABEL_55;
case 2:
v27 = 1;
goto LABEL_55;
case 4:
v27 = 2;
goto LABEL_55;
case 8:
v27 = 3;
goto LABEL_55;
case 16:
v27 = 4;
goto LABEL_55;
case 32:
v27 = 5;
goto LABEL_55;
case 128:
v27 = 6;
goto LABEL_55;
case 256:
v27 = 7;
goto LABEL_55;
case 512:
v27 = 8;
goto LABEL_55;
case 0:
v27 = 9;
LABEL_55:
v28 = dword_D33F70[v27 + 24];
*a3 = v28;
if ( a4 )
*a4 = dword_D24C40[v27];
if ( a5 )
*a5 = dword_D33F70[v27 + 36];
v20 = *a2;
if ( !*a2 )
return 0;
if ( v28 )
goto LABEL_30;
goto LABEL_29;
}
*a3 = 0;
if ( a4 )
*a4 = 0;
v20 = *a2;
if ( a5 )
*a5 = 0;
if ( *(_DWORD *)(v7 + 24) == 64 )
a4 = nullptr;
if ( !v20 )
return 0;
LABEL_29:
if ( (EVP_CIPHER_flags(v20) & 0x200000) == 0 )
return 0;
LABEL_30:
if ( a4 && !*a4 )
return 0;
if ( a7 )
return 1;
v21 = *a1 == 768;
if ( *a1 >> 8 != 3 )
v21 = 1;
if ( v21 || FIPS_mode() )
return 1;
v22 = *(_DWORD *)(v7 + 20);
if ( v22 != 4 )
{
LABEL_38:
if ( v22 == 64 )
{
v29 = *(_DWORD *)(v7 + 24);
if ( v29 != 2 )
goto LABEL_72;
cipherbyname = EVP_get_cipherbyname("AES-128-CBC-HMAC-SHA1");
if ( cipherbyname )
goto LABEL_43;
v26 = *(_DWORD *)(v7 + 20);
if ( v26 != 128 )
{
if ( v26 != 64 )
return 1;
LABEL_83:
v29 = *(_DWORD *)(v7 + 24);
LABEL_72:
if ( v29 != 16 )
return 1;
cipherbyname = EVP_get_cipherbyname("AES-128-CBC-HMAC-SHA256");
if ( !cipherbyname )
{
v30 = *(_DWORD *)(v7 + 20);
LABEL_75:
if ( v30 != 128 )
return 1;
v23 = *(_DWORD *)(v7 + 24);
goto LABEL_41;
}
LABEL_43:
*a2 = cipherbyname;
*a3 = 0;
return 1;
}
}
else if ( v22 != 128 )
{
return 1;
}
v23 = *(_DWORD *)(v7 + 24);
if ( v23 != 2 )
{
LABEL_41:
if ( v23 == 16 )
{
cipherbyname = EVP_get_cipherbyname("AES-256-CBC-HMAC-SHA256");
if ( cipherbyname )
goto LABEL_43;
}
return 1;
}
cipherbyname = EVP_get_cipherbyname("AES-256-CBC-HMAC-SHA1");
if ( cipherbyname )
goto LABEL_43;
v30 = *(_DWORD *)(v7 + 20);
if ( v30 != 64 )
goto LABEL_75;
goto LABEL_83;
}
if ( *(_DWORD *)(v7 + 24) != 1 )
return 1;
v31 = EVP_get_cipherbyname("RC4-HMAC-MD5");
if ( !v31 )
{
v22 = *(_DWORD *)(v7 + 20);
goto LABEL_38;
}
*a2 = v31;
*a3 = 0;
return 1;
}