//
// PKCS5_PBKDF2_HMAC from 0xacd1a8 to 0xacd6e4 (1340 bytes)
//
// 8 xrefs:
// > PKCS12_gen_mac @ 0xa39e64
// > PKCS12_verify_mac @ 0xa3a1c4
// > PKCS12_set_mac @ 0xa3a6bc
// > PKCS5_PBKDF2_HMAC_SHA1 @ 0xacd72c
// > PKCS5_v2_PBKDF2_keyivgen @ 0xacda9c
// > EVP_PBE_scrypt @ 0xae8578
// > EVP_PBE_scrypt @ 0xae882c
// > ??> @ 0x7f2cc
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:09:21 +0000
//
int __fastcall PKCS5_PBKDF2_HMAC(const char *a1, size_t a2, int a3, int a4, int a5, int a6, int a7, _DWORD *a8)
{
int v10; // r11
_DWORD *v11; // r10
signed int v13; // r5
int v14; // r0
unsigned int v15; // r3
unsigned int v16; // r2
unsigned int v17; // r12
_BOOL4 v18; // r1
unsigned int v19; // r3
int i; // r6
_BYTE *v21; // r1
char *v22; // r0
char v23; // r3
char v24; // t1
char v25; // t1
bool v26; // zf
int v29; // [sp+8h] [bp-8Ch]
int v30; // [sp+8h] [bp-8Ch]
_BOOL4 v31; // [sp+Ch] [bp-88h]
signed int v32; // [sp+14h] [bp-80h]
_BYTE *v33; // [sp+18h] [bp-7Ch]
_BYTE *v34; // [sp+1Ch] [bp-78h]
_BYTE *v35; // [sp+20h] [bp-74h]
signed int v36; // [sp+24h] [bp-70h]
char *v37; // [sp+28h] [bp-6Ch]
char *v38; // [sp+2Ch] [bp-68h]
char *v39; // [sp+30h] [bp-64h]
char v40; // [sp+38h] [bp-5Ch]
char v41; // [sp+4Fh] [bp-45h] BYREF
_DWORD v42[17]; // [sp+50h] [bp-44h] BYREF
v29 = EVP_MD_size(a6);
if ( v29 < 0 )
return 0;
v10 = HMAC_CTX_new();
if ( !v10 )
return 0;
if ( a1 )
{
if ( a2 == -1 )
a2 = strlen(a1);
}
else
{
a2 = 0;
}
if ( !HMAC_Init_ex(v10, a1, a2, a6, nullptr) )
{
HMAC_CTX_free(v10);
return 0;
}
v11 = (_DWORD *)HMAC_CTX_new();
if ( !v11 )
{
HMAC_CTX_free(v10);
return 0;
}
if ( !a7 )
{
LABEL_57:
HMAC_CTX_free((int)v11);
HMAC_CTX_free(v10);
return 1;
}
v40 = 1;
while ( 1 )
{
v13 = a7 >= v29 ? v29 : a7;
v41 = v40;
v14 = HMAC_CTX_copy((int)v11, v10);
if ( !v14 )
break;
if ( !HMAC_Update(v11) || !HMAC_Update(v11) || !HMAC_Final((int)v11, (int)v42, nullptr) )
{
LABEL_58:
HMAC_CTX_free((int)v11);
HMAC_CTX_free(v10);
return 0;
}
HMAC_CTX_reset((int)v11);
memcpy(a8, v42, v13);
if ( a5 > 1 )
{
v15 = 4 * (((unsigned int)(v13 - 4) >> 2) + 1);
if ( (unsigned int)(v13 - 1) <= 2 )
v15 = 0;
v16 = v15;
v17 = v15 + 2;
v18 = (unsigned int)v13 > 5 && ((unsigned __int8)a8 & 3) == 0;
v31 = v18;
v34 = (char *)a8 + v17;
v19 = v15 + 1;
v39 = (char *)&v42[16] + v17;
v35 = (char *)a8 + v19;
v32 = v19;
v38 = (char *)&v42[16] + v19;
v33 = (char *)a8 + v16;
v36 = v17;
v37 = (char *)&v42[16] + v16;
for ( i = 1; i != a5; ++i )
{
while ( 1 )
{
v14 = HMAC_CTX_copy((int)v11, v10);
if ( !v14 )
goto LABEL_62;
if ( !HMAC_Update(v11) || !HMAC_Final((int)v11, (int)v42, nullptr) )
goto LABEL_58;
HMAC_CTX_reset((int)v11);
if ( v13 > 0 )
break;
LABEL_46:
if ( ++i == a5 )
goto LABEL_55;
}
if ( v31 )
{
if ( (unsigned int)(v13 - 1) <= 2 )
goto LABEL_43;
*a8 ^= v42[0];
if ( (unsigned int)(v13 - 4) >> 2 )
{
a8[1] ^= v42[1];
if ( (unsigned int)(v13 - 4) >> 2 != 1 )
{
a8[2] ^= v42[2];
if ( (unsigned int)(v13 - 4) >> 2 != 2 )
{
a8[3] ^= v42[3];
if ( (unsigned int)(v13 - 4) >> 2 != 3 )
{
a8[4] ^= v42[4];
if ( (unsigned int)(v13 - 4) >> 2 != 4 )
{
a8[5] ^= v42[5];
if ( (unsigned int)(v13 - 4) >> 2 != 5 )
{
a8[6] ^= v42[6];
if ( (unsigned int)(v13 - 4) >> 2 != 6 )
{
a8[7] ^= v42[7];
if ( (unsigned int)(v13 - 4) >> 2 != 7 )
{
a8[8] ^= v42[8];
if ( (unsigned int)(v13 - 4) >> 2 != 8 )
{
a8[9] ^= v42[9];
if ( (unsigned int)(v13 - 4) >> 2 != 9 )
{
a8[10] ^= v42[10];
if ( (unsigned int)(v13 - 4) >> 2 != 10 )
{
a8[11] ^= v42[11];
if ( (unsigned int)(v13 - 4) >> 2 != 11 )
{
a8[12] ^= v42[12];
if ( (unsigned int)(v13 - 4) >> 2 != 12 )
{
a8[13] ^= v42[13];
if ( (unsigned int)(v13 - 4) >> 2 != 13 )
{
a8[14] ^= v42[14];
if ( (unsigned int)(v13 - 4) >> 2 != 14 )
a8[15] ^= v42[15];
}
}
}
}
}
}
}
}
}
}
}
}
}
}
if ( v13 != 4 * (((unsigned int)(v13 - 4) >> 2) + 1) )
{
LABEL_43:
*v33 ^= *(v37 - 64);
if ( v32 < v13 )
{
*v35 ^= *(v38 - 64);
if ( v13 > v36 )
*v34 ^= *(v39 - 64);
}
}
goto LABEL_46;
}
v21 = (char *)a8 - 1;
v22 = &v41;
do
{
v24 = *++v21;
v23 = v24;
v25 = *++v22;
*v21 = v23 ^ v25;
}
while ( v21 != (char *)a8 + v13 - 1 );
}
}
LABEL_55:
a8 = (_DWORD *)((char *)a8 + v13);
v26 = a7 == v13;
a7 -= v13;
++v40;
if ( v26 )
goto LABEL_57;
}
LABEL_62:
v30 = v14;
HMAC_CTX_free((int)v11);
HMAC_CTX_free(v10);
return v30;
}