//
// sub_DD47A4 from 0xdd47a4 to 0xdd4b3c (920 bytes)
//
// 1 xrefs:
// > ??> @ 0x1239068
//
// 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 sub_DD47A4(int a1, _BYTE *a2, __int64 a3, __int64 a4, int a5)
{
__int64 v10; // x0
__int64 v11; // x1
__int64 v12; // x2
__int64 v13; // x0
__int64 v14; // x20
__int64 *v15; // x25
_QWORD *v16; // x28
int v17; // w0
int v18; // w5
int v19; // w0
unsigned int v20; // w24
unsigned __int64 v21; // x23
_BYTE *v22; // x22
unsigned int v23; // w19
__int64 v25; // x3
unsigned int v26; // w0
if ( (int)BN_num_bits(*(_QWORD *)(a4 + 32)) > 0x4000 )
{
ERR_put_error(4, 103, 105, (__int64)"crypto/rsa/rsa_ossl.c", 498);
return 0xFFFFFFFFLL;
}
else
{
if ( (int)BN_ucmp(*(__int64 **)(a4 + 32), *(__int64 **)(a4 + 40)) > 0 )
{
v10 = BN_num_bits(*(_QWORD *)(a4 + 32));
if ( (int)v10 > 3072 )
{
v10 = BN_num_bits(*(_QWORD *)(a4 + 40));
if ( (int)v10 > 64 )
{
ERR_put_error(4, 103, 101, (__int64)"crypto/rsa/rsa_ossl.c", 510);
return 0xFFFFFFFFLL;
}
}
v13 = BN_CTX_new(v10, v11, v12);
v14 = v13;
if ( !v13 )
{
v21 = 0;
v22 = nullptr;
v23 = -1;
LABEL_16:
BN_CTX_free(v14);
CRYPTO_clear_free(v22, v21, (__int64)"crypto/rsa/rsa_ossl.c", 0x246u);
return v23;
}
BN_CTX_start(v13);
v15 = (__int64 *)BN_CTX_get(v14);
v16 = (_QWORD *)BN_CTX_get(v14);
v17 = BN_num_bits(*(_QWORD *)(a4 + 32));
v18 = v17 + 14;
v19 = v17 + 7;
if ( v19 >= 0 )
v18 = v19;
v20 = v18 >> 3;
v21 = v18 >> 3;
v22 = CRYPTO_malloc((void *)v21, (__int64)"crypto/rsa/rsa_ossl.c", 521);
if ( v16 == nullptr || v15 == nullptr || !v22 )
{
v23 = -1;
ERR_put_error(4, 103, 65, (__int64)"crypto/rsa/rsa_ossl.c", 523);
goto LABEL_18;
}
if ( (int)v20 < a1 )
{
v23 = -1;
ERR_put_error(4, 103, 108, (__int64)"crypto/rsa/rsa_ossl.c", 532);
goto LABEL_18;
}
if ( !BN_bin2bn(a2, a1, (__int64)v15) )
goto LABEL_23;
if ( (BN_ucmp(v15, *(__int64 **)(a4 + 32)) & 0x80000000) == 0 )
{
v23 = -1;
ERR_put_error(4, 103, 132, (__int64)"crypto/rsa/rsa_ossl.c", 541);
LABEL_18:
BN_CTX_end(v14);
goto LABEL_16;
}
if ( (*(_DWORD *)(a4 + 108) & 2) != 0
&& !BN_MONT_CTX_set_locked((__int64 *)(a4 + 112), *(_QWORD *)(a4 + 160), *(_QWORD ***)(a4 + 32), v14)
|| !(*(unsigned int (__fastcall **)(_QWORD *, __int64 *, _QWORD, _QWORD, __int64, _QWORD))(*(_QWORD *)(a4 + 16)
+ 48LL))(
v16,
v15,
*(_QWORD *)(a4 + 40),
*(_QWORD *)(a4 + 32),
v14,
*(_QWORD *)(a4 + 112)) )
{
LABEL_23:
v23 = -1;
goto LABEL_18;
}
if ( a5 == 5 )
{
if ( (*(_QWORD *)bn_get_words(v16) & 0xFLL) != 0xC && !(unsigned int)BN_sub(v16, *(_QWORD *)(a4 + 32), v16) )
goto LABEL_23;
v26 = BN_bn2bin(v16, v22);
v23 = RSA_padding_check_X931(a3, v20, v22, v26, v20);
}
else
{
v25 = (unsigned int)BN_bn2bin(v16, v22);
if ( a5 == 1 )
{
v23 = RSA_padding_check_PKCS1_type_1(a3, v20, v22, v25, v20);
}
else
{
if ( a5 != 3 )
{
v23 = -1;
ERR_put_error(4, 103, 118, (__int64)"crypto/rsa/rsa_ossl.c", 572);
goto LABEL_18;
}
v23 = RSA_padding_check_none(a3, v20, v22, v25, v20);
}
}
if ( (v23 & 0x80000000) != 0 )
ERR_put_error(4, 103, 114, (__int64)"crypto/rsa/rsa_ossl.c", 576);
goto LABEL_18;
}
ERR_put_error(4, 103, 101, (__int64)"crypto/rsa/rsa_ossl.c", 503);
return 0xFFFFFFFFLL;
}
}