//
// PKCS8_encrypt from 0xe660d4 to 0xe661f8 (292 bytes)
//
// 4 xrefs:
// > PKCS12_SAFEBAG_create_pkcs8_encrypt @ 0xdcb798
// > sub_E64EF8 @ 0xe64fb8
// > sub_E64EF8 @ 0xe65068
// > ??> @ 0x8c658
//
// 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 PKCS8_encrypt(
unsigned int a1,
__int64 a2,
const char *a3,
unsigned int a4,
const void *a5,
unsigned int a6,
unsigned int a7,
__int64 a8)
{
__int64 *v16; // x19
_QWORD *v17; // x20
if ( a1 == -1 )
{
v16 = (__int64 *)PKCS5_pbe2_set(a2, a7, a5, a6);
}
else if ( (unsigned int)EVP_PBE_find(1, a1, nullptr, nullptr, nullptr) )
{
v16 = (__int64 *)PKCS5_pbe2_set_iv(a2, a7, a5, a6, 0, a1);
}
else
{
ERR_clear_error();
v16 = PKCS5_pbe_set(a1, a7, a5, a6);
}
if ( v16 )
{
v17 = PKCS8_set0_pbe(a3, a4, a8, v16);
if ( !v17 )
X509_ALGOR_free((__int64)v16);
}
else
{
v17 = nullptr;
ERR_put_error(35, 125, 13, (__int64)"crypto/pkcs12/p12_p8e.c", 32);
}
return v17;
}