//
// RSA_padding_add_PKCS1_type_2 from 0xdd5a64 to 0xdd5b60 (252 bytes)
//
// 2 xrefs:
// > sub_DD4B3C @ 0xdd4da4
// > ??> @ 0x9c0d8
//
// 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
//
__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;
}