//
// ssl_cipher_get_evp from 0xd3cc18 to 0xd3cfd0 (952 bytes)
//
// 3 xrefs:
// > ssl3_setup_key_block @ 0xd5eff4
// > tls1_setup_key_block @ 0xd6121c
// > ??> @ 0x51288
//
// 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
//
__int64 __fastcall ssl_cipher_get_evp(__int64 a1, __int64 *a2, __int64 *a3, _DWORD *a4, _DWORD *a5, _QWORD *a6, int a7)
{
__int64 v7; // x19
int v15; // w1
__int64 v16; // x0
unsigned int v17; // w0
_BOOL4 v18; // w0
_BOOL4 v19; // w1
__int64 v21; // x5
int v22; // w5
__int64 v23; // x0
int v24; // w2
__int64 v25; // x3
int v26; // w0
int v27; // w0
__int64 cipherbyname; // x0
int v29; // w0
int v30; // w0
int v31; // w0
int v32; // [xsp+68h] [xbp+68h] BYREF
v7 = *(_QWORD *)(a1 + 216);
if ( !v7 )
return 0;
if ( !a6 )
{
v18 = a2 == nullptr;
v19 = a3 == nullptr;
goto LABEL_10;
}
CRYPTO_THREAD_run_once(algn_125D4C8, sub_D3BB18);
v15 = *(_DWORD *)(a1 + 208);
v16 = qword_125D370;
*a6 = 0;
v32 = v15;
if ( !v16 )
goto LABEL_6;
v17 = OPENSSL_sk_find(v16, &v32);
if ( (v17 & 0x80000000) == 0 )
{
*a6 = OPENSSL_sk_value(qword_125D370, v17);
LABEL_6:
v18 = a2 == nullptr;
v19 = a3 == nullptr;
if ( !a2 )
goto LABEL_7;
goto LABEL_10;
}
*a6 = 0;
v18 = a2 == nullptr;
v19 = a3 == nullptr;
if ( !a2 )
{
LABEL_7:
if ( v19 )
return 1;
goto LABEL_11;
}
LABEL_10:
if ( v19 )
return 0;
LABEL_11:
if ( v18 )
return 0;
v21 = 0;
while ( *(_DWORD *)(v7 + 28) != dword_F61FA0[2 * v21] )
{
if ( ++v21 == 20 )
{
*a2 = 0;
goto LABEL_16;
}
}
if ( v21 == 5 )
*a2 = EVP_enc_null();
else
*a2 = qword_125D380[(int)v21];
LABEL_16:
v22 = *(_DWORD *)(v7 + 32);
switch ( v22 )
{
case 1:
v24 = 0;
goto LABEL_40;
case 2:
v24 = 1;
goto LABEL_40;
case 4:
v24 = 2;
goto LABEL_40;
case 8:
v24 = 3;
goto LABEL_40;
case 16:
v24 = 4;
goto LABEL_40;
case 32:
v24 = 5;
goto LABEL_40;
case 128:
v24 = 6;
goto LABEL_40;
case 256:
v24 = 7;
goto LABEL_40;
case 512:
v24 = 8;
goto LABEL_40;
case 0:
v24 = 9;
LABEL_40:
v25 = qword_125D430[v24];
*a3 = v25;
if ( a4 )
*a4 = dword_12369B0[v24];
if ( a5 )
*a5 = dword_125D490[v24];
v23 = *a2;
if ( !*a2 )
return 0;
if ( v25 )
goto LABEL_46;
goto LABEL_33;
}
*a3 = 0;
if ( a4 )
*a4 = 0;
if ( a5 )
*a5 = 0;
v23 = *a2;
if ( *(_DWORD *)(v7 + 32) == 64 )
a4 = nullptr;
if ( !v23 )
return 0;
LABEL_33:
if ( (EVP_CIPHER_flags(v23) & 0x200000) == 0 )
return 0;
LABEL_46:
if ( a4 && !*a4 )
return 0;
if ( a7 || *(int *)a1 >> 8 != 3 || *(_DWORD *)a1 == 768 || (unsigned int)FIPS_mode() )
return 1;
v26 = *(_DWORD *)(v7 + 28);
if ( v26 == 4 )
{
if ( *(_DWORD *)(v7 + 32) != 1 )
return 1;
cipherbyname = EVP_get_cipherbyname("RC4-HMAC-MD5");
if ( cipherbyname )
goto LABEL_58;
v26 = *(_DWORD *)(v7 + 28);
}
if ( v26 != 64 )
{
if ( v26 != 128 )
return 1;
goto LABEL_55;
}
v29 = *(_DWORD *)(v7 + 32);
if ( v29 != 2 )
{
LABEL_70:
if ( v29 != 16 )
return 1;
cipherbyname = EVP_get_cipherbyname("AES-128-CBC-HMAC-SHA256");
if ( cipherbyname )
goto LABEL_58;
v30 = *(_DWORD *)(v7 + 28);
goto LABEL_73;
}
cipherbyname = EVP_get_cipherbyname("AES-128-CBC-HMAC-SHA1");
if ( cipherbyname )
goto LABEL_58;
v31 = *(_DWORD *)(v7 + 28);
if ( v31 == 128 )
{
LABEL_55:
v27 = *(_DWORD *)(v7 + 32);
if ( v27 != 2 )
{
LABEL_56:
if ( v27 != 16 )
return 1;
cipherbyname = EVP_get_cipherbyname("AES-256-CBC-HMAC-SHA256");
if ( !cipherbyname )
return 1;
goto LABEL_58;
}
cipherbyname = EVP_get_cipherbyname("AES-256-CBC-HMAC-SHA1");
if ( !cipherbyname )
{
v30 = *(_DWORD *)(v7 + 28);
if ( v30 != 64 )
{
LABEL_73:
if ( v30 != 128 )
return 1;
v27 = *(_DWORD *)(v7 + 32);
goto LABEL_56;
}
goto LABEL_80;
}
LABEL_58:
*a2 = cipherbyname;
*a3 = 0;
return 1;
}
if ( v31 == 64 )
{
LABEL_80:
v29 = *(_DWORD *)(v7 + 32);
goto LABEL_70;
}
return 1;
}