//
// PKCS5_pbkdf2_set from 0xe72998 to 0xe72b68 (464 bytes)
//
// 3 xrefs:
// > CMS_add0_recipient_password @ 0xe20ae0
// > PKCS5_pbe2_set_iv @ 0xe72c6c
// > ??> @ 0x7cf08
//
// 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
//
_QWORD *__fastcall PKCS5_pbkdf2_set(int a1, const void *a2, int a3, signed int a4, int a5)
{
__int64 *v10; // x19
__int64 v11; // x0
__int64 v12; // x20
__int64 v13; // x2
size_t v14; // x22
void *v15; // x0
__int64 v16; // x1
__int64 v17; // x0
__int64 v18; // x0
__int64 *v19; // x20
char **v20; // x0
_QWORD *v21; // x20
v10 = (__int64 *)PBKDF2PARAM_new();
if ( !v10 )
goto LABEL_21;
v11 = ASN1_OCTET_STRING_new();
v12 = v11;
if ( !v11 )
goto LABEL_21;
v13 = *v10;
v14 = a3;
*(_QWORD *)(v13 + 8) = v11;
*(_DWORD *)v13 = 4;
if ( !a3 )
{
v14 = 8;
a3 = 8;
}
v15 = CRYPTO_malloc((void *)v14, (__int64)"crypto/asn1/p5_pbev2.c", 170);
*(_QWORD *)(v12 + 8) = v15;
if ( !v15 )
goto LABEL_21;
*(_DWORD *)v12 = a3;
if ( a2 )
{
memcpy(v15, a2, v14);
}
else if ( (int)RAND_bytes((__int64)v15, (unsigned int)a3) <= 0 )
{
goto LABEL_21;
}
v16 = 2048;
if ( a1 > 0 )
v16 = a1;
if ( !(unsigned int)ASN1_INTEGER_set(v10[1], v16) )
goto LABEL_21;
if ( a5 > 0 )
{
v17 = ASN1_INTEGER_new();
v10[2] = v17;
if ( !v17 || !(unsigned int)ASN1_INTEGER_set(v17, a5) )
goto LABEL_21;
}
if ( a4 != 163 && a4 > 0 )
{
v18 = X509_ALGOR_new();
v10[3] = v18;
v19 = (__int64 *)v18;
if ( !v18 )
{
LABEL_21:
v21 = nullptr;
goto LABEL_22;
}
v20 = OBJ_nid2obj(a4);
X509_ALGOR_set0(v19, (__int64)v20, 5u, 0);
}
v21 = (_QWORD *)X509_ALGOR_new();
if ( !v21 )
goto LABEL_21;
*v21 = OBJ_nid2obj(0x45u);
if ( ASN1_TYPE_pack_sequence((__int64)PBKDF2PARAM_it, (__int64)v10, v21 + 1) )
{
PBKDF2PARAM_free((__int64)v10);
return v21;
}
LABEL_22:
ERR_put_error(13, 219, 65, (__int64)"crypto/asn1/p5_pbev2.c", 221);
PBKDF2PARAM_free((__int64)v10);
X509_ALGOR_free((__int64)v21);
return nullptr;
}