//
// PKCS5_pbe_set0_algor from 0x8675b8 to 0x867780 (456 bytes)
//
// 2 xrefs:
// > PKCS5_pbe_set @ 0x8677cc
// > ??> @ 0x69a6c
//
// 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
//
int __fastcall PKCS5_pbe_set0_algor(_DWORD **a1, unsigned int a2, int a3, const void *a4, int a5)
{
void *v9; // r0
size_t *v10; // r5
int v11; // r1
char *v12; // r4
void *v13; // r3
size_t v14; // r9
char *v15; // r0
char **v16; // r0
int v18; // [sp+Ch] [bp-4h] BYREF
v18 = 0;
v9 = PBEPARAM_new();
v10 = (size_t *)v9;
if ( v9 )
{
if ( a3 <= 0 )
v11 = 2048;
else
v11 = a3;
v12 = (char *)ASN1_INTEGER_set(*((signed int **)v9 + 1), v11);
if ( v12 )
{
v13 = (void *)a5;
if ( !a5 )
{
v13 = byte_8;
a5 = 8;
}
v14 = (size_t)v13;
v15 = (char *)CRYPTO_malloc(v13, (int)"crypto/asn1/p5_pbe.c", 48);
v12 = v15;
if ( v15 )
{
if ( a4 )
{
memcpy(v15, a4, v14);
}
else if ( RAND_bytes((int)v15, a5) <= 0 )
{
goto LABEL_15;
}
ASN1_STRING_set0((_DWORD *)*v10, (int)v12, a5);
v12 = (char *)ASN1_item_pack(v10, PBEPARAM_it, &v18);
if ( v12 )
{
PBEPARAM_free(v10);
v16 = OBJ_nid2obj(a2);
if ( X509_ALGOR_set0(a1, v16, 16, v18) )
return 1;
v12 = nullptr;
v10 = nullptr;
}
else
{
ERR_put_error(13, 215, 65, (int)"crypto/asn1/p5_pbe.c", 62);
}
}
else
{
ERR_put_error(13, 215, 65, (int)"crypto/asn1/p5_pbe.c", 50);
}
}
else
{
ERR_put_error(13, 215, 65, (int)"crypto/asn1/p5_pbe.c", 42);
}
}
else
{
ERR_put_error(13, 215, 65, (int)"crypto/asn1/p5_pbe.c", 36);
v12 = nullptr;
}
LABEL_15:
CRYPTO_free(v12, (int)"crypto/asn1/p5_pbe.c", 73);
PBEPARAM_free(v10);
ASN1_STRING_free(v18);
return 0;
}