//
// RSA_padding_add_PKCS1_type_2 from 0x82f678 to 0x82f76c (244 bytes)
//
// 2 xrefs:
// > sub_82E5F4 @ 0x82e804
// > ??> @ 0x6640c
//
// 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_add_PKCS1_type_2(_BYTE *a1, int a2, const void *a3, signed int a4)
{
int v6; // r5
unsigned __int8 *v7; // r9
unsigned __int8 *v8; // r4
unsigned __int8 *v9; // r6
int v10; // r3
int v11; // r5
if ( a2 - 10 <= a4 )
{
ERR_put_error(4, 109, 110, (int)"crypto/rsa/rsa_pk1.c", 125);
return 0;
}
else
{
v6 = a2 - 3 - a4;
*a1 = 0;
v7 = a1 + 2;
a1[1] = 2;
if ( RAND_bytes((int)(a1 + 2), v6) > 0 )
{
if ( v6 <= 0 )
{
LABEL_7:
*v7 = 0;
memcpy(v7 + 1, a3, a4);
return 1;
}
v8 = v7;
v9 = &v7[v6];
while ( 1 )
{
v10 = *v8;
v11 = (int)v8++;
if ( !v10 )
break;
LABEL_6:
v7 = v8;
if ( v8 == v9 )
goto LABEL_7;
}
while ( RAND_bytes(v11, 1) > 0 )
{
if ( *(v8 - 1) )
goto LABEL_6;
}
}
return 0;
}
}