//
// RSA_padding_check_PKCS1_type_2 from 0x82f770 to 0x82f934 (452 bytes)
//
// 2 xrefs:
// > sub_82EE80 @ 0x82f194
// > ??> @ 0x664bc
//
// 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 RSA_padding_check_PKCS1_type_2(void *a1, unsigned int a2, const void *a3, size_t a4, char *a5)
{
unsigned __int8 *v5; // r6
unsigned __int8 *v12; // r0
unsigned __int8 *v13; // lr
int v14; // r12
int v15; // r0
int v16; // r1
int v17; // t1
int v18; // r3
int v19; // r2
int v20; // r9
size_t v21; // r4
v5 = (unsigned __int8 *)((a4 >> 31) | (a2 >> 31));
if ( v5 )
return -1;
if ( (int)a4 > (int)a5 || (int)a5 <= 10 )
goto LABEL_6;
v12 = (unsigned __int8 *)CRYPTO_zalloc(a5, (int)"crypto/rsa/rsa_pk1.c", 178);
v5 = v12;
if ( v12 )
{
memcpy(&a5[(_DWORD)v12 - a4], a3, a4);
v13 = v5 + 1;
v14 = 0;
v15 = 0;
v16 = 2;
do
{
v17 = *++v13;
v18 = ((v17 - 1) & ~v17) >> 31;
v19 = v18 & ~v15;
v20 = v19 & v16++;
v14 = v14 & ~v19 | v20;
v15 |= v18;
}
while ( (int)a5 > v16 );
v21 = (size_t)&a5[-v14 - 1];
if ( ((((*v5 - 1) & ~*v5) >> 31)
& ((((v5[1] ^ 2) - 1) & ~(v5[1] ^ 2)) >> 31)
& ~((v14 ^ ((v14 - 10) ^ 0xA | v14 ^ 0xA)) >> 31)
& ~((int)(a2 ^ ((a2 - v21) ^ v21 | v21 ^ a2)) >> 31)) == 0 )
{
LABEL_6:
CRYPTO_free(v5, (int)"crypto/rsa/rsa_pk1.c", 240);
LABEL_7:
ERR_put_error(4, 113, 159, (int)"crypto/rsa/rsa_pk1.c", 243);
return -1;
}
memcpy(a1, &v5[v14 + 1], v21);
CRYPTO_free(v5, (int)"crypto/rsa/rsa_pk1.c", 240);
if ( v21 == -1 )
goto LABEL_7;
return v21;
}
else
{
ERR_put_error(4, 113, 65, (int)"crypto/rsa/rsa_pk1.c", 180);
return -1;
}
}