//
// PKCS1_MGF1 from 0xe6af50 to 0xe6b0b4 (356 bytes)
//
// 7 xrefs:
// > RSA_verify_PKCS1_PSS_mgf1 @ 0xdd73bc
// > RSA_padding_add_PKCS1_PSS_mgf1 @ 0xdd7cac
// > RSA_padding_add_PKCS1_OAEP_mgf1 @ 0xe6b2a8
// > RSA_padding_add_PKCS1_OAEP_mgf1 @ 0xe6b6b0
// > RSA_padding_check_PKCS1_OAEP_mgf1 @ 0xe6bbb4
// > RSA_padding_check_PKCS1_OAEP_mgf1 @ 0xe6bec0
// > ??> @ 0x2cef8
//
// 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 PKCS1_MGF1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 *v8; // x20
int v9; // w0
__int64 v10; // x25
__int64 v11; // x24
__int64 v12; // x22
__int64 v13; // x19
__int64 v14; // x21
int v15; // w0
__int64 v16; // x1
unsigned int v17; // w19
_BYTE v19[64]; // [xsp+80h] [xbp+80h] BYREF
v8 = (__int64 *)EVP_MD_CTX_new();
if ( !v8 || (v9 = EVP_MD_size(a5), v9 < 0) )
{
LABEL_15:
v17 = -1;
goto LABEL_14;
}
if ( a2 > 0 )
{
v10 = v9;
v11 = a1;
v12 = 0;
v13 = 0;
do
{
v14 = v10 + v12;
++v13;
if ( !(unsigned int)EVP_DigestInit_ex(v8, a5, 0) )
goto LABEL_15;
if ( !(unsigned int)EVP_DigestUpdate((__int64)v8) )
goto LABEL_15;
v15 = EVP_DigestUpdate((__int64)v8);
v16 = v11;
if ( !v15 )
goto LABEL_15;
if ( a2 < v14 )
{
if ( !(unsigned int)EVP_DigestFinal_ex((int **)v8, (__int64)v19, nullptr) )
goto LABEL_15;
v17 = 0;
memcpy((void *)(a1 + v12), v19, a2 - v12);
goto LABEL_14;
}
v12 += v10;
v11 += v10;
if ( !(unsigned int)EVP_DigestFinal_ex((int **)v8, v16, nullptr) )
goto LABEL_15;
}
while ( a2 > v14 );
}
v17 = 0;
LABEL_14:
EVP_MD_CTX_free(v8);
return v17;
}