//
// sub_79B558 from 0x79b558 to 0x79b6e0 (392 bytes)
//
// 2 xrefs:
// > SSL_use_certificate @ 0x79b9a8
// > SSL_CTX_use_certificate @ 0x79c258
//
// 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 sub_79B558(_DWORD *a1, int a2)
{
int v4; // r9
int v5; // r0
int v6; // r8
int v7; // r1
int v8; // r0
_DWORD *v9; // r5
int can_sign; // r10
int v12; // r0
int v13; // r0
int v14; // r0
v4 = X509_get0_pubkey(a2);
if ( v4 )
{
v5 = ssl_cert_type(a2, v4);
v6 = v5;
if ( v5 < 0 )
{
ERR_put_error(20, 191, 247, "ssl/ssl_rsa.c", 324);
return 0;
}
else if ( v5 != 3 || (v14 = EVP_PKEY_get0_EC_KEY(v4), (can_sign = EC_KEY_can_sign(v14)) != 0) )
{
v7 = a1[5 * v6 + 6];
if ( v7 )
{
v8 = EVP_PKEY_copy_parameters(v4, v7);
ERR_clear_error(v8);
if ( EVP_PKEY_id(a1[5 * v6 + 6]) != 6 || (v12 = EVP_PKEY_get0_RSA(a1[5 * v6 + 6]), (RSA_flags(v12) & 1) == 0) )
{
if ( !X509_check_private_key(a2, a1[5 * v6 + 6]) )
{
v13 = EVP_PKEY_free(a1[5 * v6 + 6]);
a1[5 * v6 + 6] = 0;
ERR_clear_error(v13);
}
}
}
v9 = &a1[5 * v6];
X509_free(v9[5]);
can_sign = 1;
X509_up_ref(a2);
v9[5] = a2;
*a1 = v9 + 5;
}
else
{
ERR_put_error(20, 191, 318, "ssl/ssl_rsa.c", 329);
}
return can_sign;
}
else
{
ERR_put_error(20, 191, 268, "ssl/ssl_rsa.c", 318);
return 0;
}
}