//
// PKCS5_pbe_set0_algor from 0x108d9f0 to 0x108dbcc (476 bytes)
//
// 2 xrefs:
// > PKCS5_pbe_set @ 0x108dc0c
// > ??> @ 0x5b3f0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:17:16 +0000
//
__int64 __fastcall PKCS5_pbe_set0_algor(__int64 *a1, unsigned int a2, int a3, const void *a4, int a5)
{
__int64 v9; // x0
__int64 *v10; // x19
__int64 v11; // x1
__int64 v12; // x0
size_t v13; // x23
void *v14; // x0
void *v15; // x20
char **v16; // x0
int v17; // w0
unsigned int v18; // w1
__int64 v21; // [xsp+78h] [xbp+78h] BYREF
v21 = 0;
v9 = PBEPARAM_new();
v10 = (__int64 *)v9;
if ( !v9 )
{
v15 = nullptr;
ERR_put_error(13, 215, 65, (__int64)"crypto/asn1/p5_pbe.c", 36);
goto LABEL_13;
}
v11 = 2048;
v12 = *(_QWORD *)(v9 + 8);
if ( a3 > 0 )
v11 = a3;
if ( !(unsigned int)ASN1_INTEGER_set(v12, v11) )
{
v15 = nullptr;
ERR_put_error(13, 215, 65, (__int64)"crypto/asn1/p5_pbe.c", 42);
goto LABEL_13;
}
v13 = a5;
if ( !a5 )
{
v13 = 8;
a5 = 8;
}
v14 = CRYPTO_malloc((void *)v13, (__int64)"crypto/asn1/p5_pbe.c", 48);
v15 = v14;
if ( !v14 )
{
ERR_put_error(13, 215, 65, (__int64)"crypto/asn1/p5_pbe.c", 50);
goto LABEL_13;
}
if ( a4 )
{
memcpy(v14, a4, v13);
}
else if ( (int)RAND_bytes((__int64)v14, (unsigned int)a5) <= 0 )
{
goto LABEL_13;
}
ASN1_STRING_set0(*v10, (__int64)v15, a5);
v15 = (void *)ASN1_item_pack((__int64)v10, (__int64)PBEPARAM_it, &v21);
if ( !v15 )
{
ERR_put_error(13, 215, 65, (__int64)"crypto/asn1/p5_pbe.c", 62);
goto LABEL_13;
}
PBEPARAM_free((__int64)v10);
v16 = OBJ_nid2obj(a2);
v17 = X509_ALGOR_set0(a1, (__int64)v16, 0x10u, v21);
v18 = 1;
if ( !v17 )
{
v15 = nullptr;
v10 = nullptr;
LABEL_13:
CRYPTO_free(v15, (__int64)"crypto/asn1/p5_pbe.c", 73);
PBEPARAM_free((__int64)v10);
ASN1_STRING_free(v21);
return 0;
}
return v18;
}