//
// RSA_new_method from 0x10521b8 to 0x1052384 (460 bytes)
//
// 2 xrefs:
// > RSA_new @ 0x1052388
// > ??> @ 0xa31b0
//
// 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:39 +0000
//
void *__fastcall RSA_new_method(__int64 a1)
{
void *v2; // x19
__int64 v3; // x0
__int64 v4; // x21
__int64 default_method; // x0
__int64 default_RSA; // x0
__int64 RSA; // x0
unsigned int (__fastcall *v8)(void *); // x1
v2 = CRYPTO_zalloc(&qword_A8, (__int64)"crypto/rsa/rsa_lib.c", 72);
if ( !v2 )
{
v4 = 0;
ERR_put_error(4, 106, 65, (__int64)"crypto/rsa/rsa_lib.c", 75);
return (void *)v4;
}
*((_DWORD *)v2 + 26) = 1;
v3 = CRYPTO_THREAD_lock_new(1);
*((_QWORD *)v2 + 20) = v3;
v4 = v3;
if ( !v3 )
{
ERR_put_error(4, 106, 65, (__int64)"crypto/rsa/rsa_lib.c", 82);
CRYPTO_free(v2, (__int64)"crypto/rsa/rsa_lib.c", 83);
return (void *)v4;
}
default_method = RSA_get_default_method();
*((_QWORD *)v2 + 2) = default_method;
*((_DWORD *)v2 + 27) = *(_DWORD *)(default_method + 72) & 0xFFFFFBFF;
if ( a1 )
{
if ( !(unsigned int)ENGINE_init(a1) )
{
ERR_put_error(4, 106, 38, (__int64)"crypto/rsa/rsa_lib.c", 92);
goto LABEL_13;
}
*((_QWORD *)v2 + 3) = a1;
default_RSA = a1;
goto LABEL_6;
}
default_RSA = ENGINE_get_default_RSA();
*((_QWORD *)v2 + 3) = default_RSA;
if ( default_RSA )
{
LABEL_6:
RSA = ENGINE_get_RSA(default_RSA);
*((_QWORD *)v2 + 2) = RSA;
if ( !RSA )
{
ERR_put_error(4, 106, 38, (__int64)"crypto/rsa/rsa_lib.c", 101);
goto LABEL_13;
}
goto LABEL_7;
}
RSA = *((_QWORD *)v2 + 2);
LABEL_7:
*((_DWORD *)v2 + 27) = *(_DWORD *)(RSA + 72) & 0xFFFFFBFF;
if ( (unsigned int)CRYPTO_new_ex_data(9u, (__int64)v2, (_QWORD *)v2 + 12) )
{
v8 = *(unsigned int (__fastcall **)(void *))(*((_QWORD *)v2 + 2) + 56LL);
if ( !v8 )
return v2;
v4 = (__int64)v2;
if ( v8(v2) )
return (void *)v4;
ERR_put_error(4, 106, 70, (__int64)"crypto/rsa/rsa_lib.c", 113);
}
LABEL_13:
RSA_free((__int64)v2);
return nullptr;
}