//
// PKCS8_encrypt from 0x8bbc08 to 0x8bbd10 (264 bytes)
//
// 4 xrefs:
// > PKCS12_SAFEBAG_create_pkcs8_encrypt @ 0x825f08
// > sub_8BAB28 @ 0x8bab8c
// > sub_8BAB28 @ 0x8bac6c
// > ??> @ 0x6596c
//
// 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 PKCS8_encrypt(
unsigned int a1,
int a2,
const char *a3,
size_t a4,
const void *a5,
int a6,
int a7,
size_t *a8)
{
int *v12; // r5
_DWORD *result; // r0
if ( a1 == -1 )
{
v12 = (int *)PKCS5_pbe2_set(a2, a7, a5, a6);
}
else if ( EVP_PBE_find(1, a1, nullptr, nullptr, nullptr) )
{
v12 = (int *)PKCS5_pbe2_set_iv(a2, a7, (int)a5, a6, nullptr, a1);
}
else
{
ERR_clear_error();
v12 = PKCS5_pbe_set(a1, a7, a5, a6);
}
if ( v12 )
{
result = PKCS8_set0_pbe(a3, a4, a8, v12);
if ( !result )
{
X509_ALGOR_free(v12);
return nullptr;
}
}
else
{
ERR_put_error(35, 125, 13, (int)"crypto/pkcs12/p12_p8e.c", 32);
return nullptr;
}
return result;
}