//
// sub_A42E10 from 0xa42e10 to 0xa431bc (940 bytes)
//
// 1 xrefs:
// > ??> @ 0xd26004
//
// 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:08:14 +0000
//
int __fastcall sub_A42E10(int a1, _BYTE *a2, int a3, int a4, int a5)
{
int v7; // r0
int v8; // r0
int v9; // r6
int *v10; // r8
_DWORD *v11; // r10
int v12; // r0
int v13; // r5
signed int v14; // r5
_BYTE *v15; // r0
bool v16; // zf
int v17; // r2
_BYTE *v18; // r7
int v19; // r4
int v21; // r0
int v22; // r0
if ( BN_num_bits(*(_DWORD **)(a4 + 16)) > 0x4000 )
{
ERR_put_error(4, 103, 105, (int)"crypto/rsa/rsa_ossl.c", 498);
return -1;
}
else
{
if ( BN_ucmp(*(int **)(a4 + 16), *(int **)(a4 + 20)) > 0 )
{
v7 = BN_num_bits(*(_DWORD **)(a4 + 16));
if ( v7 > 3072 )
{
v7 = BN_num_bits(*(_DWORD **)(a4 + 20));
if ( v7 > 64 )
{
ERR_put_error(4, 103, 101, (int)"crypto/rsa/rsa_ossl.c", 510);
return -1;
}
}
v8 = BN_CTX_new(v7);
v9 = v8;
if ( !v8 )
{
v14 = 0;
v18 = nullptr;
v19 = -1;
LABEL_22:
BN_CTX_free(v9);
CRYPTO_clear_free(v18, v14, (int)"crypto/rsa/rsa_ossl.c", 582);
return v19;
}
BN_CTX_start(v8);
v10 = (int *)BN_CTX_get(v9);
v11 = (_DWORD *)BN_CTX_get(v9);
v12 = BN_num_bits(*(_DWORD **)(a4 + 16));
v13 = v12 + 7;
if ( v12 + 7 < 0 )
v13 = v12 + 14;
v14 = v13 >> 3;
v15 = CRYPTO_malloc((void *)v14, (int)"crypto/rsa/rsa_ossl.c", 521);
v16 = v10 == nullptr;
if ( v10 )
v16 = v11 == nullptr;
v17 = v16;
if ( !v15 )
v17 |= 1u;
v18 = v15;
if ( v17 )
{
ERR_put_error(4, 103, 65, (int)"crypto/rsa/rsa_ossl.c", 523);
v19 = -1;
goto LABEL_24;
}
if ( v14 < a1 )
{
ERR_put_error(4, 103, 108, (int)"crypto/rsa/rsa_ossl.c", 532);
v19 = -1;
goto LABEL_24;
}
if ( !BN_bin2bn(a2, a1, v10) )
goto LABEL_29;
if ( BN_ucmp(v10, *(int **)(a4 + 16)) >= 0 )
{
ERR_put_error(4, 103, 132, (int)"crypto/rsa/rsa_ossl.c", 541);
v19 = -1;
LABEL_24:
BN_CTX_end(v9);
goto LABEL_22;
}
if ( (*(_DWORD *)(a4 + 56) & 2) != 0
&& !BN_MONT_CTX_set_locked((_BYTE **)(a4 + 60), *(_DWORD *)(a4 + 84), *(int ***)(a4 + 16), v9)
|| !(*(int (__fastcall **)(_DWORD *, int *, _DWORD, _DWORD, int, _DWORD))(*(_DWORD *)(a4 + 8) + 24))(
v11,
v10,
*(_DWORD *)(a4 + 20),
*(_DWORD *)(a4 + 16),
v9,
*(_DWORD *)(a4 + 60)) )
{
LABEL_29:
v19 = -1;
goto LABEL_24;
}
if ( a5 == 5 )
{
if ( (*(_DWORD *)bn_get_words(v11) & 0xF) != 0xC && !BN_sub(v11, *(_DWORD *)(a4 + 16), v11) )
goto LABEL_29;
v22 = BN_bn2bin(v11, v18);
v19 = RSA_padding_check_X931(a3, v14, v18, v22, v14);
}
else
{
v21 = BN_bn2bin(v11, v18);
if ( a5 == 1 )
{
v19 = RSA_padding_check_PKCS1_type_1(a3, v14, v18, v21, v14);
}
else
{
if ( a5 != 3 )
{
ERR_put_error(4, 103, 118, (int)"crypto/rsa/rsa_ossl.c", 572);
v19 = -1;
goto LABEL_24;
}
v19 = RSA_padding_check_none(a3, v14, v18, v21, v14);
}
}
if ( v19 < 0 )
ERR_put_error(4, 103, 114, (int)"crypto/rsa/rsa_ossl.c", 576);
goto LABEL_24;
}
ERR_put_error(4, 103, 101, (int)"crypto/rsa/rsa_ossl.c", 503);
return -1;
}
}