//
// sub_10545B8 from 0x10545b8 to 0x1054a18 (1120 bytes)
//
// 1 xrefs:
// > ??> @ 0x140dff8
//
// 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 sub_10545B8(__int64 a1, int a2, int a3, unsigned int *a4)
{
__int64 v6; // x22
__int64 v7; // x20
__int64 v9; // x0
v6 = a3;
v7 = *(_QWORD *)(a1 + 40);
if ( a2 == 4098 )
goto LABEL_53;
if ( a2 <= 4098 )
{
if ( a2 == 7 )
return 1;
if ( a2 <= 7 )
{
if ( a2 == 2 )
{
ERR_put_error(4, 143, 148, (__int64)"crypto/rsa/rsa_pmeth.c", 509);
return 4294967294LL;
}
if ( a2 <= 2 )
{
if ( a2 != 1 )
return 4294967294LL;
if ( (unsigned int)sub_10544A8(a4, *(_DWORD *)(v7 + 24)) )
{
*(_QWORD *)(v7 + 32) = a4;
return (unsigned int)a2;
}
return 0;
}
if ( a2 > 5 )
return 4294967294LL;
return 1;
}
if ( a2 == 13 )
goto LABEL_44;
if ( a2 <= 13 )
{
if ( (unsigned int)(a2 - 9) > 2 )
return 4294967294LL;
return 1;
}
if ( a2 != 4097 )
return 4294967294LL;
if ( (unsigned int)(a3 - 1) <= 5 )
{
if ( !(unsigned int)sub_10544A8(*(unsigned int **)(v7 + 32), a3) )
return 0;
if ( (_DWORD)v6 == 6 )
{
if ( (*(_DWORD *)(a1 + 32) & 0x18) != 0 )
goto LABEL_30;
}
else
{
if ( (_DWORD)v6 != 4 )
{
LABEL_32:
*(_DWORD *)(v7 + 24) = v6;
return 1;
}
if ( (*(_DWORD *)(a1 + 32) & 0x300) != 0 )
{
LABEL_30:
if ( !*(_QWORD *)(v7 + 32) )
*(_QWORD *)(v7 + 32) = EVP_sha1();
goto LABEL_32;
}
}
}
ERR_put_error(4, 143, 144, (__int64)"crypto/rsa/rsa_pmeth.c", 396);
return 4294967294LL;
}
if ( a2 == 4103 )
{
LABEL_53:
if ( *(_DWORD *)(v7 + 24) != 6 )
{
ERR_put_error(4, 143, 146, (__int64)"crypto/rsa/rsa_pmeth.c", 406);
return 4294967294LL;
}
if ( a2 == 4103 )
{
*a4 = *(_DWORD *)(v7 + 48);
return 1;
}
if ( a3 >= -2 )
{
*(_DWORD *)(v7 + 48) = a3;
return 1;
}
return 4294967294LL;
}
if ( a2 <= 4103 )
{
if ( a2 == 4100 )
{
if ( a4 && (unsigned int)BN_is_odd((__int64)a4) && !(unsigned int)BN_is_one((__int64)a4) )
{
BN_free(*(_QWORD *)(v7 + 8));
*(_QWORD *)(v7 + 8) = a4;
return 1;
}
else
{
ERR_put_error(4, 143, 101, (__int64)"crypto/rsa/rsa_pmeth.c", 428);
return 4294967294LL;
}
}
if ( a2 < 4100 )
{
if ( a3 <= 511 )
{
ERR_put_error(4, 143, 120, (__int64)"crypto/rsa/rsa_pmeth.c", 420);
return 4294967294LL;
}
else
{
*(_DWORD *)v7 = a3;
return 1;
}
}
if ( a2 != 4101 )
{
*a4 = *(_DWORD *)(v7 + 24);
return 1;
}
goto LABEL_45;
}
if ( a2 == 4106 )
{
if ( *(_DWORD *)(v7 + 24) == 4 )
{
CRYPTO_free(*(void **)(v7 + 64), (__int64)"crypto/rsa/rsa_pmeth.c", 478);
if ( (int)v6 > 0 && a4 )
{
*(_QWORD *)(v7 + 64) = a4;
*(_QWORD *)(v7 + 72) = v6;
return 1;
}
else
{
*(_QWORD *)(v7 + 64) = 0;
*(_QWORD *)(v7 + 72) = 0;
return 1;
}
}
else
{
ERR_put_error(4, 143, 141, (__int64)"crypto/rsa/rsa_pmeth.c", 475);
return 4294967294LL;
}
}
if ( a2 <= 4106 )
{
if ( a2 == 4104 )
{
LABEL_45:
if ( (*(_DWORD *)(v7 + 24) & 0xFFFFFFFD) == 4 )
{
if ( a2 != 4104 )
{
*(_QWORD *)(v7 + 40) = a4;
return 1;
}
v9 = *(_QWORD *)(v7 + 40);
if ( v9 )
{
*(_QWORD *)a4 = v9;
return 1;
}
LABEL_44:
*(_QWORD *)a4 = *(_QWORD *)(v7 + 32);
return 1;
}
ERR_put_error(4, 143, 156, (__int64)"crypto/rsa/rsa_pmeth.c", 461);
return 4294967294LL;
}
}
else if ( a2 != 4107 )
{
if ( a2 == 4108 )
{
if ( *(_DWORD *)(v7 + 24) == 4 )
{
*(_QWORD *)a4 = *(_QWORD *)(v7 + 64);
return *(unsigned int *)(v7 + 72);
}
else
{
ERR_put_error(4, 143, 141, (__int64)"crypto/rsa/rsa_pmeth.c", 490);
return 4294967294LL;
}
}
return 4294967294LL;
}
if ( *(_DWORD *)(v7 + 24) == 4 )
{
if ( a2 != 4107 )
{
*(_QWORD *)(v7 + 32) = a4;
return 1;
}
goto LABEL_44;
}
ERR_put_error(4, 143, 141, (__int64)"crypto/rsa/rsa_pmeth.c", 438);
return 4294967294LL;
}