//
// PKCS1_MGF1 from 0x8bff9c to 0x8c00d4 (312 bytes)
//
// 7 xrefs:
// > RSA_verify_PKCS1_PSS_mgf1 @ 0x831028
// > RSA_padding_add_PKCS1_PSS_mgf1 @ 0x831624
// > RSA_padding_add_PKCS1_OAEP_mgf1 @ 0x8c026c
// > RSA_padding_add_PKCS1_OAEP_mgf1 @ 0x8c036c
// > RSA_padding_check_PKCS1_OAEP_mgf1 @ 0x8c07f8
// > RSA_padding_check_PKCS1_OAEP_mgf1 @ 0x8c0a5c
// > ??> @ 0x6657c
//
// 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 PKCS1_MGF1(int a1, int a2, int a3, int a4, int a5)
{
int *v7; // r5
int v8; // r9
int v9; // r7
int v10; // r4
int v11; // r6
int v12; // r0
int v13; // r1
int v14; // r4
_BYTE v16[68]; // [sp+10h] [bp-44h] BYREF
v7 = (int *)EVP_MD_CTX_new();
if ( !v7 || (v8 = EVP_MD_size(a5), v8 < 0) )
{
LABEL_17:
v14 = -1;
goto LABEL_16;
}
if ( a2 > 0 )
{
v9 = 0;
v10 = 0;
do
{
v11 = v9 + v8;
++v10;
if ( !EVP_DigestInit_ex(v7, a5, nullptr) )
goto LABEL_17;
if ( !EVP_DigestUpdate((int)v7) )
goto LABEL_17;
v12 = EVP_DigestUpdate((int)v7);
v13 = a1 + v9;
if ( !v12 )
goto LABEL_17;
if ( a2 < v11 )
{
if ( !EVP_DigestFinal_ex((int **)v7, (int)v16, nullptr) )
goto LABEL_17;
memcpy((void *)(a1 + v9), v16, a2 - v9);
break;
}
v9 += v8;
if ( !EVP_DigestFinal_ex((int **)v7, v13, nullptr) )
goto LABEL_17;
}
while ( a2 > v11 );
}
v14 = 0;
LABEL_16:
EVP_MD_CTX_free(v7);
return v14;
}