//
// PKCS5_v2_PBE_keyivgen from 0x8b8738 to 0x8b88d8 (416 bytes)
//
// 2 xrefs:
// > ??> @ 0x6b08c
// > ??> @ 0xab52dc
//
// 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
//
_DWORD *__fastcall PKCS5_v2_PBE_keyivgen(int *a1, int a2, int a3, _DWORD *a4, int a5, int a6, int a7)
{
int **v10; // r0
int **v11; // r5
char *v12; // r0
_DWORD *v13; // r4
char *v14; // r0
char *v15; // r0
int *cipherbyname; // r0
int (__fastcall *v18)(int *, int, int, int, _DWORD, _DWORD, int); // [sp+14h] [bp-8h] BYREF
v10 = (int **)ASN1_TYPE_unpack_sequence((int)&PBE2PARAM_it, a4);
v11 = v10;
if ( v10 )
{
v12 = OBJ_obj2nid(**v10);
v13 = EVP_PBE_find(2, (int)v12, nullptr, nullptr, &v18);
if ( v13 )
{
v14 = OBJ_obj2nid(*v11[1]);
v15 = OBJ_nid2sn((unsigned int)v14);
cipherbyname = (int *)EVP_get_cipherbyname((int)v15);
v13 = cipherbyname;
if ( cipherbyname )
{
if ( EVP_CipherInit_ex(a1, cipherbyname, nullptr, 0, nullptr, a7) )
{
if ( EVP_CIPHER_asn1_to_param((int)a1, v11[1][1]) < 0 )
{
v13 = nullptr;
ERR_put_error(6, 118, 122, (int)"crypto/evp/p5_crpt2.c", 189);
}
else
{
v13 = (_DWORD *)v18(a1, a2, a3, (*v11)[1], 0, 0, a7);
}
}
else
{
v13 = nullptr;
}
}
else
{
ERR_put_error(6, 118, 107, (int)"crypto/evp/p5_crpt2.c", 181);
}
}
else
{
ERR_put_error(6, 118, 124, (int)"crypto/evp/p5_crpt2.c", 170);
}
}
else
{
ERR_put_error(6, 118, 114, (int)"crypto/evp/p5_crpt2.c", 162);
v13 = nullptr;
}
PBE2PARAM_free(v11);
return v13;
}