//
// RSA_padding_add_PKCS1_type_2 from 0x1053dc4 to 0x1053ec0 (252 bytes)
//
// 2 xrefs:
// > sub_1052E9C @ 0x1053104
// > ??> @ 0xcd8b8
//
// 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_add_PKCS1_type_2(_BYTE *a1, int a2, const void *a3, unsigned int a4)
{
int v6; // w20
_BYTE *v7; // x19
_BYTE *v8; // x20
if ( a2 - 10 <= (int)a4 )
{
ERR_put_error(4, 109, 110, (__int64)"crypto/rsa/rsa_pk1.c", 125);
return 0;
}
v6 = a2 - 3 - a4;
*a1 = 0;
v7 = a1 + 2;
a1[1] = 2;
if ( (int)RAND_bytes((__int64)(a1 + 2), (unsigned int)v6) <= 0 )
return 0;
if ( v6 > 0 )
{
v8 = &v7[v6 - 1 + 1];
while ( *v7 )
{
LABEL_6:
if ( ++v7 == v8 )
goto LABEL_7;
}
while ( (int)RAND_bytes((__int64)v7, 1) > 0 )
{
if ( *v7 )
goto LABEL_6;
}
return 0;
}
v8 = v7;
LABEL_7:
*v8 = 0;
memcpy(v8 + 1, a3, a4);
return 1;
}