//
// RSA_padding_check_PKCS1_type_2 from 0x1053ec0 to 0x1054098 (472 bytes)
//
// 2 xrefs:
// > sub_10536BC @ 0x10539dc
// > ??> @ 0xa7968
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:16:40 +0000
//
__int64 __fastcall RSA_padding_check_PKCS1_type_2(void *a1, int a2, const void *a3, int a4, int a5)
{
unsigned __int8 *v10; // x25
__int64 result; // x0
__int64 v12; // x26
unsigned __int8 *v13; // x0
int v14; // w2
unsigned __int8 *v15; // x8
int v16; // w4
int i; // w6
int v18; // t1
int v19; // w7
int v20; // w5
int v21; // w7
int v22; // w20
if ( a2 < 0 || a4 < 0 )
return 0xFFFFFFFFLL;
if ( a4 > a5 || a5 <= 10 )
{
v10 = nullptr;
LABEL_6:
CRYPTO_free(v10, (__int64)"crypto/rsa/rsa_pk1.c", 240);
LABEL_7:
ERR_put_error(4, 113, 159, (__int64)"crypto/rsa/rsa_pk1.c", 243);
return 0xFFFFFFFFLL;
}
v12 = a5;
v13 = (unsigned __int8 *)CRYPTO_zalloc((void *)a5, (__int64)"crypto/rsa/rsa_pk1.c", 178);
v10 = v13;
if ( !v13 )
{
ERR_put_error(4, 113, 65, (__int64)"crypto/rsa/rsa_pk1.c", 180);
return 0xFFFFFFFFLL;
}
memcpy(&v13[v12 - a4], a3, a4);
v14 = 0;
v15 = v10 + 2;
v16 = 0;
for ( i = 2; i < a5; ++i )
{
v18 = *v15++;
v19 = ((v18 - 1) & ~v18) >> 31;
v20 = v19 & ~v16;
v16 |= v19;
v21 = v20 & i;
v14 = v14 & ~v20 | v21;
}
v22 = a5 - (v14 + 1);
if ( ((((*v10 - 1) & ~*v10) >> 31)
& ((((v10[1] ^ 2) - 1) & ~(v10[1] ^ 2)) >> 31)
& ~((((v14 - 10) ^ 0xA | v14 ^ 0xA) ^ v14) >> 31)
& ~((((a2 - v22) ^ v22 | v22 ^ a2) ^ a2) >> 31)) == 0 )
goto LABEL_6;
memcpy(a1, &v10[v14 + 1], v22);
CRYPTO_free(v10, (__int64)"crypto/rsa/rsa_pk1.c", 240);
result = (unsigned int)v22;
if ( v22 == -1 )
goto LABEL_7;
return result;
}